2012-03-19 72 views
1

我想查找一個註冊表,但它始終返回-1(不存在),即使它實際存在。RegDBKeyExists總是返回-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; 

回答

3

如果你檢查是否key exists那麼你必須這樣做:

reg = RegDBKeyExist("SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v4\\Full"); 

RegDBKeyexist will only check if a key exists, not a value.flexerasoftware.com

檢查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

+0

這正是問題所在!謝謝! – 2012-03-20 11:34:55