Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / writing to the registry

Author
Message
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 12th Apr 2008 15:55
anyone has experience creating registry entries in C++ and writing string values to the registry?

i have been searching for long and i have only found long and complicated examples. All i need is to create a subfolder, create a key and write a string value.

thanks a lot.
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 12th Apr 2008 17:07
solved my own problem!

for anyone who is interested in creating registry keys, here is a working example:

Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 12th Apr 2008 17:32
Would you mind explaining what that does? Registry is one thing that's escaped me to this point, probably for the very reason you cited.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 12th Apr 2008 17:39
The last argument passed to RegSetValueEx is supposed to be the size of the data, in this case the size of the string (including the null terminator). You appear to be passing the size of DWORD.

bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 13th Apr 2008 08:11
thanks Benjamin that seems to be something wierd I did there, I have to fix it then. still this code works perfectly
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 13th Apr 2008 08:14
Lilith:

this code simply creates a new entry in the registry (RegCreateKeyEx) under HKEY_LOCAL_MACHINE\SOFTWARE\MY PROG NAME

Then using RegSetValueEx, it creates a new string key (My Value) and sets it to "Hello".

then it closes the registry key (RegCloseKey)

this way your program can store setup information (or any other data) in registry.

Login to post a reply

Server time is: 2024-09-29 17:33:58
Your offset time is: 2024-09-29 17:33:58