Installer: Detect TortoiseGitPlink from TortoiseGit
[msysgit.git] / share / WinGit / putty.inc.iss
blob38b791ebc4b84b6d579dcab1bbad6a30505c1da1
1 [Code]
3 const
4 TortoiseGitInstallKey='SOFTWARE\TortoiseGit';
5 TortoiseSVNInstallKey='SOFTWARE\TortoiseSVN';
6 TortoiseCVSUninstallKey='SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\TortoiseCVS_is1';
7 PuTTYUninstallKey='SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\PuTTY_is1';
8 PuTTYPrivateKeyAssoc='PuTTYPrivateKey\shell\open\command';
10 // Tries to detect the path to a PuTTY installation / an application that comes
11 // with an improved version of Plink. TortoisePlink from TortoiseGit/SVN features a
12 // GUI dialog to accept new host keys, for example.
13 // Prefer TortoiseGitPlink (optimized for Git) over TortoisePlink.
14 function GuessPlinkExecutable:string;
15 begin
16 // Prefer TortoisePlink over vanilla Plink for its GUI dialog to accept host keys.
17 if (IsWin64 and RegQueryStringValue(HKEY_LOCAL_MACHINE_64,TortoiseGitInstallKey,'Directory',Result)) or
18 RegQueryStringValue(HKEY_LOCAL_MACHINE_32,TortoiseGitInstallKey,'Directory',Result) then begin
19 // C:\Program Files\TortoiseGit\
20 Result:=Result+'bin\';
21 // C:\Program Files\TortoiseGit\bin\
22 end else if (IsWin64 and RegQueryStringValue(HKEY_LOCAL_MACHINE_64,TortoiseSVNInstallKey,'Directory',Result)) or
23 RegQueryStringValue(HKEY_LOCAL_MACHINE_32,TortoiseSVNInstallKey,'Directory',Result) then begin
24 // C:\Program Files\TortoiseSVN\
25 Result:=Result+'bin\';
26 // C:\Program Files\TortoiseSVN\bin\
27 end else begin
28 if not (IsWin64 and RegQueryStringValue(HKEY_LOCAL_MACHINE_64,TortoiseCVSUninstallKey,'InstallLocation',Result)) then begin
29 RegQueryStringValue(HKEY_LOCAL_MACHINE_32,TortoiseCVSUninstallKey,'InstallLocation',Result);
30 end;
31 // C:\Program Files\TortoiseCVS\
32 end;
34 if DirExists(Result) then begin
35 if FileExists(Result+'TortoiseGitPlink.exe') then begin
36 Result:=Result+'TortoiseGitPlink.exe'
37 Exit;
38 end;
40 Result:=Result+'TortoisePlink.exe'
41 Exit;
42 end;
44 if not RegQueryStringValue(HKEY_LOCAL_MACHINE,PuTTYUninstallKey,'InstallLocation',Result) then begin
45 if RegQueryStringValue(HKEY_CLASSES_ROOT,PuTTYPrivateKeyAssoc,'',Result) then begin
46 // "C:\Program Files\PuTTY\pageant.exe" "%1"
47 Result:=RemoveQuotes(Result);
48 // C:\Program Files\PuTTY\pageant.exe" "%1
49 Result:=ExtractFilePath(Result);
50 end;
51 end;
52 // C:\Program Files\PuTTY\
54 if not DirExists(Result) then begin
55 // Guess something.
56 Result:=ExpandConstant('{pf}\PuTTY\');
57 end;
59 Result:=Result+'plink.exe'
60 end;
62 function IsPlinkExecutable(Path:String):Boolean;
63 begin
64 Result:=(Pos('plink',LowerCase(ExtractFileName(Path)))>0);
65 end;