Cannot read registry keys under HKLM in Windows Server 2008 RRS feed

  • Question

  • My application works well in XP and Windows server 2003. But it will cause "** has stopped working" error dialog. And it is found that the error resulted from line 7 -- RegQueryValueEx. And the application would raise such error both run as admin and non-admin.

    Maybe this is due to LUA bugs in Windows Server 2008. But RegQueryValueEx is to read KKEY_LOCAL_MACHINE value and it is known that LUA users have read-only access to this registry.


    (1)                long error=    ::RegOpenKeyEx(hKey,lpSubKey,ulOptions,samDesired,&hItem);
    (2)               if(error!=ERROR_SUCCESS)
    (3)                {
    (4)                   AfxMessageBox(csMessage, MB_OK | MB_ICONSTOP, NULL);
    (5)                    return;
    (6)                }
    (7)               error=::RegQueryValueEx(hItem,lpValueName,NULL,NULL,(LPBYTE)(LPCSTR)dataStr,&dataSize);
    (8)                ::RegCloseKey(hItem);

    Do you have any idea of this problem?

    Wednesday, August 18, 2010 9:14 AM