Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

RegQueryValueEx causes Error 234

Posted on 2008-11-12
2
Medium Priority
?
1,991 Views
Last Modified: 2012-06-21
Hello

I have this code in two programs.   In one program it works perfectly.  
On the other program (same machine) the result is 234 at the first reading.  Keeping the program turned on and quering the same function will not return an error and read the details as needed.

Any comments?

Thanks

Wli
templong = RegQueryValueEx(hKey,
                                             TEXT("MyEntry"),
                                             NULL,
                                             NULL,
                                             (LPBYTE)&MyVariable,
		  &lBytesRead) ;

Open in new window

0
Comment
Question by:afikim
2 Comments
 
LVL 31

Accepted Solution

by:
Zoppo earned 500 total points
ID: 22941573
Hi afikim,

the return value 234 means 'ERROR_MORE_DATA'. The size of the data to read is passed with the last parameter. In your case the size passed there is too small for the data, the size needed is returned with 'lBytesRead' - so the next call succeeds.

If you know how many bytes to read you can simply initialize it before - if you don't know the size it's common to do it like this:

Since you use a instance to a variable I guess it should be enough to initialize lBytesRead before like this:

> lBytesRead = sizeof( MyVariable );

Hope that helps,

ZOPPO
0
 

Author Closing Comment

by:afikim
ID: 31515926
OoooooPS....

Hi Zoppo

How did I forget that???

Thanks for your help

Eli
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Question has a verified solution.

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

Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
Suggested Courses

580 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