RegQueryValueEx返回ERROR_SUCCESS,但读取的值(DWORD)始终为0

时间:2019-06-07 04:39:14

标签: visual-c++ mfc registry registrykey

RegQueryValueEx返回ERROR_SUCCESS,但读取的值(DWORD)始终为0,而​​实际上在注册表中为非零。下面是我正在查询的带有突出显示的注册表项的图像。

enter image description here

请帮助解决此问题。我如何获得正确的价值。下面是用于查询值的代码段。

HKEY hKey;
DWORD dwVal;
DWORD dwCount = sizeof(DWORD);
CString strPathMPSettings = "SOFTWARE\\Novellus Systems\\Proteus\\" + strGrpName + "\\" +  strUserName + "\\MyProteusSettings";
if(RegOpenKeyEx( HKEY_CURRENT_USER, strPathMPSettings, 0, KEY_QUERY_VALUE, &hKey ) == ERROR_SUCCESS)
{
    if(RegQueryValueEx(hKey, "USER_SETTINGS", NULL, NULL, (LPBYTE)&dwVal, &dwCount) == ERROR_SUCCESS)
    {
        //Code statements in this section is executed.
    }
}

0 个答案:

没有答案