Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Error 234 with CRegKey. Empty String values.

Posted on 1998-10-20
2
428 Views
Last Modified: 2008-03-10
When I use CRegKey.QueryValue I get the correct number of letters in the string, but my LPTSTR is always empty. The error that is returned is 234 which is ERROR_MORE_DATA. What does this mean? And why does it only do half of what it's supposed to do?

//Here is the line (note, opening the key is ERROR_SUCCESS):
error_num = key.QueryValue(lpStringVal, "LocalService", &dwStringSize);

//dwStringSize is 39 (the correct number)
//but lpStringVal is empty.
0
Comment
Question by:xxchange
2 Comments
 

Accepted Solution

by:
dirty_dog earned 50 total points
ID: 1175653
You need to initialize dwStringSize to the maximum number of letters that lpStringVal can hold.  Then QueryValue will replace it with the letters actually read.

This allows you to query the value once with 0 bytes, allocate enough memory to hold the value, and then query again for the actual value.
0
 

Author Comment

by:xxchange
ID: 1175654
Thanks alot. Worked like a charm. You rock.


0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

790 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