c++读注册表

清泛原创
直接上代码:
CString key;
key.Format(_T("Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\xxx"));
HKEY hKey;
LONG rc = RegOpenKey(HKEY_LOCAL_MACHINE, key, &hKey);
if (ERROR_SUCCESS == rc)
{
        WCHAR szBuffer[MAX_PATH];
        DWORD dwBufferSize = sizeof(szBuffer);
        rc = RegQueryValueEx(hKey, _T("Path"), NULL, NULL, (LPBYTE)szBuffer, &dwBufferSize);
        if (ERROR_SUCCESS == rc)
        {
                path = szBuffer;  //处理读出来的值
                RegCloseKey(hKey);
         }
}

c++ 注册表

分享到:
评论加载中,请稍后...
创APP如搭积木 - 创意无限,梦想即时!
回到顶部