how to read a DWORD value from registry
-
Can someone please tell me how I can read a DWORD value from the registry and display it as a decimal. I registry API function that I have looked at seem only to be able to read a string value. Help with this is most appreciated. - SAK
There are countless registry articles on CP, but here is a function I use:
DWORD CGlobalUtility::GetRegDWORD(HKEY hKey, CString cstrSubKey, CString cstrVar)
{
DWORD dwRetVal = 0;
DWORD dwTemp, dwSize = sizeof(DWORD);
HKEY phkResult;if (RegOpenKeyEx(hKey, cstrSubKey, 0, KEY\_QUERY\_VALUE, &phkResult) == ERROR\_SUCCESS) { RegQueryValueEx(phkResult, cstrVar, NULL, &dwTemp, (LPBYTE)&dwRetVal, &dwSize); RegCloseKey(phkResult); } return dwRetVal;
};
Jason Henderson
start page ; articles henderson is coming henderson is an opponent's worst nightmare * googlism * -
There are countless registry articles on CP, but here is a function I use:
DWORD CGlobalUtility::GetRegDWORD(HKEY hKey, CString cstrSubKey, CString cstrVar)
{
DWORD dwRetVal = 0;
DWORD dwTemp, dwSize = sizeof(DWORD);
HKEY phkResult;if (RegOpenKeyEx(hKey, cstrSubKey, 0, KEY\_QUERY\_VALUE, &phkResult) == ERROR\_SUCCESS) { RegQueryValueEx(phkResult, cstrVar, NULL, &dwTemp, (LPBYTE)&dwRetVal, &dwSize); RegCloseKey(phkResult); } return dwRetVal;
};
Jason Henderson
start page ; articles henderson is coming henderson is an opponent's worst nightmare * googlism *oops. take out that CGlobalUtility stuff.
Jason Henderson
start page ; articles henderson is coming henderson is an opponent's worst nightmare * googlism * -
Can someone please tell me how I can read a DWORD value from the registry and display it as a decimal. I registry API function that I have looked at seem only to be able to read a string value. Help with this is most appreciated. - SAK
For your case reading the value as a string is the best thing. Then all you need is to convert it to a double using atof or _tcstod (for UNICODE). Regards, Alvaro
Well done is better than well said. -- Benjamin Franklin (I actually prefer medium-well.)