Registry - Win 95/Win NT 
Author Message
 Registry - Win 95/Win NT

When I run this code in Windows 95, the code works fine, however, when run
on NT, the ReqQueryValueEx returns an error of :
//
// MessageId: ERROR_INVALID_PARAMETER
//
// MessageText:
//
//  The parameter is incorrect.
//
#define ERROR_INVALID_PARAMETER          87L    // dderror

The code is called multiple times for different values.  I get no return at
all.  I am reading string values.  Any help would be appreciated.
Here is the code:

CString CErpm95App::GetUserRegistry(CString strSubKey)
{
        HKEY hkCurrent = NULL;
        unsigned long ulReserved = 0;
           DWORD dwReserved = 0;

        CString strEntry;
        CString strSetting;
        CString strRegKey;
        strRegKey.LoadString(IDS_REGISTRY_KEY);

        if(RegOpenKeyEx(HKEY_USERS, strRegKey, ulReserved,
                KEY_READ, &hkCurrent) == ERROR_SUCCESS) {

                AfxMessageBox("Inside - Will do query");
                //unsigned long ulType;
                DWORD dwType;
                //BYTE byteValue;
                DWORD dwValueLength = 40;
                unsigned char* ucValue;
                unsigned long ulValueLen = 40;

                ucValue = (unsigned char*) calloc(sizeof(char),ulValueLen);

                long lError;

                CString csTemp1;
                csTemp1.Format("hkCurrent = %x, %s, %x, %x, %s, %x", hkCurrent,
strSubKey,
                        dwReserved, dwType, ucValue, dwValueLength);
                AfxMessageBox(csTemp1);
                if(ERROR_SUCCESS != (lError = RegQueryValueEx(hkCurrent, strSubKey,
                        &dwReserved, &dwType /*&ulType*/, ucValue, &dwValueLength)))
                {
                        CString csError;
                        csError.Format("RegQueryValue Failed - %d", lError);
                        AfxMessageBox(csError);
                }
                CString csTemp2;
                csTemp2.Format("hkCurrent = %x, %s, %x, %x, %s, %x", hkCurrent,
strSubKey,
                        dwReserved, dwType, ucValue, dwValueLength);
                AfxMessageBox(csTemp2);
                strEntry = ucValue;

                free(ucValue);          
        }

// Debug ONLY - Remove for final
        AfxMessageBox(strEntry);

        return strEntry;

Quote:
}



Fri, 14 Jan 2000 03:00:00 GMT  
 Registry - Win 95/Win NT

Quote:

> When I run this code in Windows 95, the code works fine, however, when
> run
> on NT, the ReqQueryValueEx returns an error of :
> //
> // MessageId: ERROR_INVALID_PARAMETER
[...]
> if(ERROR_SUCCESS != (lError = RegQueryValueEx(hkCurrent, strSubKey,
>     &dwReserved, &dwType /*&ulType*/, ucValue, &dwValueLength)))

[...]

That third parameter, dwReserved?  According to the online dox, you have
to pass NULL, not an actual address.

-- Aaron
---------------------
Aaron J Margosis

ScrnSaveSwitch/Plus - Screen Saver Control Utility:
http://members.aol.com/aaronmarg/ssswitch/



Fri, 14 Jan 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Win NT 4.0 - Win 95 Registry Reading Problems

2. Win 95/95 to Win NT

3. Win NT to Win 95

4. Porting application from Win 95 to Win NT

5. Q: Differences WIN NT / WIN 95 in VC++ 5.0

6. Win NT vs. Win 95

7. DLL on Win NT vs. Win 95

8. DLL on Win NT vs. Win 95

9. Win NT vs Win 95/98

10. Win NT to Win 95

11. Win 95 -> Win NT

12. Dialog behaviour in Win 95 and Win NT

 

 
Powered by phpBB® Forum Software