You are passing the address of a
DWORD
value as output buffer and the address
MAX_PATH
as pointer to the size parameter. But
RegQueryValueEx
requires the address of a buffer that can hold the data specified by the
lpcpData
parameter which must be passed as address of a
DWORD
to receive the data length read from the registry.
So you have an access violation and a buffer overrun.
A workin code would look like:
char lpszBuffer[MAX_PATH];
DWORD dwSize = MAX_PATH;
RegQueryvalueEx(hKey, "", NULL, NULL, LPBYTE(lpszBuffer), &dwSize);