Andreas Masur
May 23rd, 2003, 03:55 PM
Q: How can I read data from the registry?
A:
HKEY hKey;
DWORD dwSize = 0;
DWORD dwDataType = 0;
DWORD dwValue = 0;
if(::RegOpenKeyEx(HKEY_LOCAL_MACHINE,
"System\\CurrentControlSet\\Control\\Windows",
0,
KEY_QUERY_VALUE,
&hKey) == ERROR_SUCCESS)
{
// Get CSD version
dwSize = sizeof(dwValue);
if(::RegQueryValueEx(hKey,
"CSDVersion",
0,
&dwDataType,
reinterpret_cast<BYTE *>(&dwValue),
&dwSize) != ERROR_SUCCESS)
{
// Close key
::RegCloseKey(hKey);
// Error handling
}
else
{
// Work with value
// Close key
::RegCloseKey(hKey);
}
}
else
// Error handling;
<br>
A:
HKEY hKey;
DWORD dwSize = 0;
DWORD dwDataType = 0;
DWORD dwValue = 0;
if(::RegOpenKeyEx(HKEY_LOCAL_MACHINE,
"System\\CurrentControlSet\\Control\\Windows",
0,
KEY_QUERY_VALUE,
&hKey) == ERROR_SUCCESS)
{
// Get CSD version
dwSize = sizeof(dwValue);
if(::RegQueryValueEx(hKey,
"CSDVersion",
0,
&dwDataType,
reinterpret_cast<BYTE *>(&dwValue),
&dwSize) != ERROR_SUCCESS)
{
// Close key
::RegCloseKey(hKey);
// Error handling
}
else
{
// Work with value
// Close key
::RegCloseKey(hKey);
}
}
else
// Error handling;
<br>