MSDN解释
LONG RegQueryValueEx(
HKEY hKey,
LPCTSTR lpValueName,
LPDWORD lpReserved,
LPDWORD lpType,
LPBYTE lpData,
LPDWORD lpcbData
);
the buffer specified by lpData parameter is not large enough to hold the data, the function returns ERROR_MORE_DATA and stores the required buffer size in the variable pointed to bylpcbData. In this case, the contents of the lpData buffer are undefined.
If lpData is NULL, and lpcbData is non-NULL, the function returns ERROR_SUCCESS and stores the size of the data, in bytes, in the variable pointed to bylpcbData. This enables an application to determine the best way to allocate a buffer for the value's data.
char* buffer = NULL;
DWORD dwBytes=0;
DWORD dwType;
DWORD dwRet;
dwRet = RegQueryValueExA(hKey, "...", NULL, &dwType, NULL, &dwBytes);
if (ERROR_SUCCESS