I'm having a problem with the RegQueryValueEx function - it's returning error code 87 (Invalid Parameter), and it's due to the 5th parameter. I know this, because it returns ERROR_SUCCESS if I make this parameter NULL.
The "Password" registry value is a string, by the way. Does anybody know what I'm doing wrong here? I've looked through all the examples in the Visual C++ documentation, and found no clues. I've seen this argument typecast to LPCTSTR or LPTSTR, but this won't compile. I've also tried using a char* argument, and allocating memory to it with malloc, but this shouldn't make a difference, and it didn't.
A possibly related problem is that in my Project Settings/C/C++ Tab/Preprocessor Category, I have undefined WIN32_EXTRA_LEAN in order for the compiler to include "winreg.h", which is needed for the registry API. However, if I uncomment the #ifdef WIN32_EXTRA_LEAN directive, I find that WIN32_EXTRA_LEAN *is* defined. I cannot figure this out - I'm working around it by just explicitly including "winreg.h".
DWORD dwcbData = sizeof(sPwdReg);