Hello,
Simply, parameter 5 is the address to the data of your buffer and parameter 6 is the address of data buffer size.
I don't make a habit of posting code, though I think it may be beneficial. I apologize for using printf() and other C-style functions in the C++ board. So, here is an example I wrote on how to query a registry key. It may help gear you in the right direction:
Code:
#include <windows.h>
#include <stdio.h>
int checkKey(HKEY tree, const char *folder, char *key) {
long lRet;
HKEY hKey;
char temp[150];
DWORD dwBufLen;
// Open location
lRet = RegOpenKeyEx( tree, folder, 0, KEY_QUERY_VALUE, &hKey );
if (lRet != ERROR_SUCCESS)
return 0;
// Get key
dwBufLen = sizeof(temp);
lRet = RegQueryValueEx( hKey, key, NULL, NULL, (BYTE*)&temp, &dwBufLen );
if (lRet != ERROR_SUCCESS)
return 0;
printf("Key value: %s\n", temp);
// Close key
lRet = RegCloseKey( hKey );
if (lRet != ERROR_SUCCESS)
return 0;
// Got this far, then key exists
return 1;
}
int main() {
printf("Checking for key: HKEY_CURRENT_USER -> Control Panel -> Desktop -> Wallpaper\n");
if (checkKey(HKEY_CURRENT_USER, "Control Panel\\Desktop", "Wallpaper"))
printf("Key Exists.\n");
else
printf("Key Does Not Exist.\n");
return 0;
}
RegQueryValueEx()
The RegQueryValueEx function retrieves the type and data for a specified value name associated with an open registry key.
Code:
LONG RegQueryValueEx(
HKEY hKey, // handle of key to query
LPTSTR lpValueName, // address of name of value to query
LPDWORD lpReserved, // reserved
LPDWORD lpType, // address of buffer for value type
LPBYTE lpData, // address of data buffer
LPDWORD lpcbData // address of data buffer size
);
Or learn more about it here.
There are other functions, though simply doing an MSDN/Google search may pull up further documentation on such functions within the windows header file.
If you have any further questions please feel free to ask.
- Stack Overflow