Solved

Win32 RegSetValue variable

Posted on 1997-02-23
2
471 Views
Last Modified: 2013-12-04
Hi,

I want to stores data in the value field of an open registry key
with RegSetValue but value to store is a CString variable.

How do I do ?

CString exemple;

RegSetValueEx(hKey3, "file", 0, REG_SZ, (LPBYTE)exemple, 14 );
0
Comment
Question by:puce020497
2 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 0 total points
ID: 1334181
What you can do is the following,
RegSetValueEx(hKey3, "file", 0, REG_SZ, (CONST BYTE *)exemple, exemple.GetLength());
0
 

Expert Comment

by:gurumike
ID: 1334182
Actually, you need to change that last parameter to exemple.GetLength()+1, since the registry needs to allocate enough space to include the terminating null character.
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 tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
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…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

910 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