Solved

Registry String Array in CString how do I parse it?

Posted on 2000-03-09
1
381 Views
Last Modified: 2013-11-20
Hi out there,
as usually I've got a problem :)
I want to put a string array to the registry and read it back. For writing I use the function RegSetValueEx with parameter REG_MULTI_SZ.
The data that I pass to this function is created like this:

CString s;
s += _T("test");
s += _T("\n");
s += _T("string2");
s += _T("\n");

Now my first question ist the "\n" the correct separation character or should I use _T((char)0)); ?

Lets go on with reading.
The RegQueryValueEx function fills my CString but when I run IsEmpty() it always returns true. :(
Why?

Help

Tobias
0
Comment
Question by:SirSmokeALot
1 Comment
 
LVL 9

Accepted Solution

by:
ShaunWilde earned 50 total points
ID: 2600383
the RegSetValueEx type is a double NULL terminated list adn will not be possible to make using a CString.

By double NULL terminated list I mean the following

"test\0string2\0\0"

so what you need to do is create a char array that is big enough for all you strings and the null seperators in this case it is strlen("test")+strlen("string2")+3 (1 for each NULL '\0')

then copy them into your buffer putting the nulls in he correct places.

to extract is a bit easier

use RegQueryValueEx(...) to determine the size of the string and create you receiving buffer and then call RegQueryValueEx(...) again.

you then have to parse your string (pseudo code)

to get test out (char *buffer)

char *p=buffer;
CString szTest=p;
p+=szTest.GetLength()+1; // the plus one is to step past the NULL
CString szSecondString=p;

etc repeat until there are no more strings left ie p==NULL;

Or alternatively you can get a registry handling class from http://www.codeguru.com/system/index.shtml
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Unix / Linux grid computing 5 126
move a line in eclipse 3 60
fizzArray  challenge 1 47
how to split multiple lines delimiter : 8 53
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

708 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

20 Experts available now in Live!

Get 1:1 Help Now