Inno Setup - How can I tell the installation when it execute Google Chrome, it should open stackoverflow.com?

后端 未结 1 354
梦毁少年i
梦毁少年i 2020-12-16 03:52

By following this: https://productforums.google.com/forum/#!topic/chrome/8XnSOnhLBzA

  • Went to http://ninite.com/chrome/ to get their chrome installer (but th

相关标签:
1条回答
  • 2020-12-16 03:55

    The following might work, since the registry key I'm referring to, is described in the official docs for the Chrome installer. There is one registry key which directly contains a path to the chrome.exe file so it's IMHO the best choice to get the Chrome app. file name. It is this key:

    <root>\Software\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe
    

    Where the <root> is either HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER registry root depending on whether the Chrome has been installed for the current user or globally for the whole system.

    In the following script I'm using the above key not only for getting the Chrome app. file name, but even for determining if the Chrome is installed:

    [Files]
    Source: "chrome_installer.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall
    
    [Run]
    Filename: "{tmp}\chrome_installer.exe"; Check: not IsChromeInstalled
    Filename: "{code:GetChromeFileName}"; Parameters: "www.stackoverflow.com"; \
        Check: IsChromeInstalled
    
    [Code]
    const
      ChromeAppRegKey = 'Software\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe';
    
    function IsChromeInstalled: Boolean;
    begin
      { check if there's the Chrome app registration entry under the HKCU, or }
      { HKLM root key, return the result }
      Result := RegKeyExists(HKEY_CURRENT_USER, ChromeAppRegKey) or
        RegKeyExists(HKEY_LOCAL_MACHINE, ChromeAppRegKey);
    end;
    
    function GetChromeFileName(Value: string): string;
    var
      S: string;
    begin
      { initialize returned value to an empty string }
      Result := '';
      { first attempt to read the Chrome app file name from the HKCU root key; }
      { if that fails, try to read the same from HKLM; if any of that succeed, }
      { return the obtained registry value }
      if RegQueryStringValue(HKEY_CURRENT_USER, ChromeAppRegKey, '', S) or
        RegQueryStringValue(HKEY_LOCAL_MACHINE, ChromeAppRegKey, '', S)
      then
        Result := S;
    end;
    
    0 讨论(0)
提交回复
热议问题