Insert DWORD to registry using Reg

  • Follow


Hi everybody,
I need to insert a DWORD value into the registry.
I exported a key to a file and tried to insert it back to the
registry.
My key was of type DWORD. for example: "ColorTable02"=dword:00008000

I've done that with the following code:

//  string sKey  =  "ColorTable02"
//  string sData  =  "00008000"

dwType = REG_DWORD;
dwSize = sizeof(DWORD);

int i = atoi(sData.c_str());

RegSetValueEx(hKey,sKey.c_str(),0,dwType,(PBYTE)&i,dwSize);

It work's fine BUT when sData contains letters such as "00f08a00". It
won't work.
offcourse it's because of the atoi function BUT I have no idea which
other function can do the work.

Thanks
Dave.
0
Reply daved170 12/28/2009 7:30:28 PM

On Mon, 28 Dec 2009 11:30:28 -0800 (PST), daved170 <daved170@gmail.com> wrote:

|It work's fine BUT when sData contains letters such as "00f08a00". It
|won't work.
|offcourse it's because of the atoi function BUT I have no idea which
|other function can do the work.

strtoul()

You can specify hex (base = 16).
-- 
 - Vince
0
Reply Vincent 12/28/2009 7:58:53 PM


1 Replies
595 Views

(page loaded in 0.249 seconds)

Similiar Articles:













7/24/2012 1:55:03 AM


Reply: