请问,我想实现的是:能够通过下面脚本检测目前注册表中是否有(HKEY_LOCAL_MACHINE, 'SOFTWARE\TouchDev\touchdev\1.00.000') 和(HKEY_LOCAL_MACHINE, 'SOFTWARE\Free Interactive Technology\fitouch\1.00.000')之中的一个存在。如有的话,那么就将Gallery补丁安装在该程序目前所在的目录下,但是通过下面的代码中,只能实现将其安装在 C:\Program Files\Gallery中,请问下面的脚本是DefaultDirName的路径没定义好,还是code段中的代码有问题?如何实现啊?希望高手们指点指点!(查过论坛中的帖子,但目前安装路径问题依然解决不了)
[Setup]
AppId={{6260B099-DFBE-4ACE-968B-9392640AA073}
AppName=Gallery
AppVersion=1.0
DefaultDirName={code:GetPath}
DefaultGroupName=Gallery
OutputDir=C:\Users\IBM\Desktop
OutputBaseFilename=Gallery
Compression=lzma
SolidCompression=yes
Uninstallable = no
[Languages]
Name: "chinesesimp"; MessagesFile: "compiler:Default.isl"
[Files]
Source: "C:\Users\IBM\Desktop\Gallery\Gallery\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
[code]
function ShouldSkipPage(PageID: Integer): Boolean;
begin
result := false;
if PageID = wpSelectDir then result := true;
end;
function InitializeSetup(): Boolean;
begin
Result := true;
if not (RegKeyExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\TouchDev\touchdev\1.00.000') or RegKeyExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\Free Interactive Technology\fitouch\1.00.000')) then
begin
MsgBox('未检测到原安装程序,请先安装!', mbInformation, MB_OK);
Result := False;
end;
end;
function GetPath(Param: String): String;
var
strPath: String;
begin
strPath := ExpandConstant('{pf}\Gallery');
if RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\TouchDev\touchdev\1.00.000', 'Path', strPath) then
begin
strPath := ExtractFilePath(strPath);
end;
if RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Free Interactive Technology\fitouch\1.00.000', 'Path', strPath) then
begin
strPath := ExtractFilePath(strPath);
end;
Result := strPath;
end;