我想寻找一个注册表,但它总是返回-1(不存在),即使它实际存在也是如此。
请查看我的代码,看看我是否遗漏了某些内容:
export prototype installFramework(HWND);
function installFramework(hMSI)
STRING szProgram, szKey, szName, szValue, szMsg;
NUMBER reg, nSize, nResult;
begin
REGDB_OPTIONS = REGDB_OPTIONS | REGDB_OPTION_WOW64_64KEY;
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
reg = RegDBKeyExist("SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v4\\Full\\Install");
if (reg < 0) then
szMsg = "Message here.";
MessageBox (szMsg, INFORMATION);
szProgram = INSTALLDIR ^ "dotnetfx40_full_x86_x64.exe";
LaunchAppAndWait(szProgram, "", WAIT );
endif;
end;
答案 0 :(得分:3)
如果您正在检查key exists
是否必须这样做:
reg = RegDBKeyExist("SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v4\\Full");
来自flexerasoftware.com 的 RegDBKeyexist will only check if a key exists, not a value.
检查To find out if a value exists then you can use the RegDBGetKeyValueEx function and check if it fails to get the value.
RegDBKeyExist("SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v4\\Full\\Install");
其中Install
是一个值,因此它给了您-1