Re: Difference between CRegKey::QueryStringValue and RegQueryValueEx



Yes thats a bug in the line before it returns ERROR_INVALID_DATA, I have my own Registry class, and check it with my class
quickly, and I also get the same answer, that it is expected, return value, ERROR_SUCCESS, and buffer is empty string.
Good Catch!

"Mihajlo Cvetanovic" <mac@xxxxxxxxxxxxxxxxxx> wrote in message news:eLAaiXcQFHA.204@xxxxxxxxxxxxxxxxxxxxxxx
> When you run this code (on VC++ 7.1 Standard, with _LIBS_USER_FULL_VER
> defined as "7.10.3077" in atlbuild.h) QueryStringValue will return
> ERROR_INVALID_DATA and RegQueryValueEx will return 0 (with cbZeroSize =
> 0). Is there some fix or service pack for this bug, and is it removed
> from .NET 2005?
>
> #include <windows.h>
> #include <atlbase.h>
>
> int _tmain(int argc, TCHAR* argv[])
> {
> LONG nRC;
> CRegKey key;
> nRC = key.Create( HKEY_LOCAL_MACHINE, _T("Software\\Testing") );
> nRC = RegSetValueEx( key, _T("ZeroSize"), 0, REG_SZ, NULL, 0 );
>
> TCHAR szZeroSize[20];
> DWORD cbZeroSize, dwValueType;
>
> cbZeroSize = sizeof( szZeroSize ) / sizeof( TCHAR );
> nRC = key.QueryStringValue( _T("ZeroSize"), szZeroSize, &cbZeroSize );
>
> cbZeroSize = sizeof( szZeroSize );
> nRC = RegQueryValueEx( key, _T("ZeroSize"), NULL, &dwValueType,
> (LPBYTE)szZeroSize, &cbZeroSize );
>
> return 0;
> }


.


Loading