Solved

RegQueryValueEx( ) fails on NT, works on Win95?

Posted on 1997-05-16
3
551 Views
Last Modified: 2013-12-03
I have Registry-reading code that works fine on Win95, and fails on NT4; here's a snippet:HKEY hKey(NULL);DWORD dwDisp(0L);// First open the key (if it's there).if (ERROR_SUCCESS == ::RegOpenKeyEx(  HKEY_CURRENT_USER,  "Software\\MyCompany\\MyApp\\CustomerColWidths",  0L,  KEY_READ,  &hKey)) {   // If key there, open columns until you run out.   LONG lnReturn(ERROR_SUCCESS);   for (int nCol = 0; ERROR_SUCCESS == lnReturn; nCol++) {      CString sValueName;      sValueName.Format("Column%d", nCol);      DWORD dwReserved(0L);      DWORD dwType(0L);      DWORD dwData(0L);      DWORD dwDataSize(sizeof(DWORD));      BYTE* pData = reinterpret_cast<BYTE*> (&dwData);                              if (ERROR_SUCCESS == (lnReturn = ::RegQueryValueEx(        hKey,        sValueName,        &dwReserved,        &dwType,        pData,        &dwDataSize))) {                                       VERIFY(SetColumnWidth(nCol, dwData));      }      else {         // Be sure it failed because this column wasn't found in Registry.         ASSERT(ERROR_FILE_NOT_FOUND == lnReturn);      }   }   VERIFY(ERROR_SUCCESS == ::RegCloseKey(hKey));   hKey = NULL;}  On NT4, RegQueryValueEx( ) returns 87L (an illegal parameter) every time it executes.  The identical code runs fine on Win95.  The funny part is that this is *reading* a key, and it fails - *writing* a key, using ::RegSetValueEx( ), works fine on both systems.Any ideas?
0
Comment
Question by:laleonard
  • 2
3 Comments
 

Author Comment

by:laleonard
ID: 1397390
Edited text of question
0
 
LVL 1

Accepted Solution

by:
ete earned 50 total points
ID: 1397391
The LPDWORD lpReserved parameter must explicitly be NULL.

if (ERROR_SUCCESS == (lnReturn =
::RegQueryValueEx(
hKey,
sValueName,
NULL,
&dwType,
pData,
&dwDataSize)))

This should solve your problem

Best regards
ETE
0
 

Author Comment

by:laleonard
ID: 1397392
Well, duh!!  Thanks (grinning sheepishly)...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now