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

Registry String Array in CString how do I parse it?

Posted on 2000-03-09
1
408 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

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

Title # Comments Views Activity
Replacement selected text 2 63
countEvens challenge 2 111
matchUp  challenge 6 68
Updating statistics with error notification email in SQL server 4 109
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

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