在 setup.exe 安装过程中,如果注册表中存在特定键,我想中止安装。为此,我正在使用 install shield 项目中的自定义操作调用 install-script 函数。安装脚本代码是:
function MyFunction(hMSI)
// To Do: Declare local variables.
STRING szKey;
NUMBER nRootKey;
begin
// Set the root key to HKEY_LOCAL_MACHINE.
nRootKey = HKEY_LOCAL_MACHINE;
if (RegDBSetDefaultRoot (nRootKey) < 0) then
MessageBox ("First call to RegDBSetDefaultRoot failed.", SEVERE);
else
MessageBox ("Root key successfully set to HKEY_LOCAL_MACHINE.",
INFORMATION);
endif;
szKey = "SOFTWARE\\Test";
if (RegDBKeyExist (szKey)< 0) then
MessageBox ("Test is not present", SEVERE);
abort;
endif;
if (RegDBKeyExist (szKey)= 1) then
MessageBox ("Test is present", SEVERE);
abort;
endif;
// To Do: Write script that will be executed when MyFunction is called.
end;
每次我收到消息“测试不存在”时,即使注册表中存在键“HKEY_LOCAL_MACHINE\SOFTWARE\Test”。
我想我在脚本中做错了什么或遗漏了一些东西。请帮助解决这个问题。
https://community.flexerasoftware.com/showthread.php?139026-Check-if-a-registry-key-exists