I've been bashing my head about this and can't find any good examples of how to read a binary registry entry. Here's what I have...
Code:
int ReadBinary(HKEY hKey, char *pszKey, char *pszValue, void *pvRet) {
HKEY lRegHandle = 0;
long lResult = 0;
DWORD dwType = REG_BINARY
DWORD dwBufSize = 0;
/* Open key but do not create if it doesn't exist. */
lRegHandle = OpenKey(hKey, pszKey, 0);
/* Call RegQueryValueEx to get the buffer size. */
lResult = RegQueryValueEx(lRegHandle, pszValue, 0, &dwType, 0, &dwBufSize);
if (lResult == ERROR_SUCCESS) {
/* Get Data. */
lResult = RegQueryValueEx(lRegHandle, pszValue, 0, &dwType, (unsigned char*)pvRet, &dwBufSize);
CloseKey(hKey);
if (lResult == ERROR_SUCCESS) {
char szBuf[255];
wsprintf(szBuf, "Data size = %d, string = %s", dwBufSize, szRet);
MessageBox(0, szBuf, "ReadBinary", 0);
return 1;
}
}
}
The Data size comes out fine, but I get garbage for the string. It's probably something simple but I can't find anything really useful on Google or MSDN.