C++ registry stuff

Status
Not open for further replies.

Erlehacker

Posts: 12   +0
I need to know how to create/modify registry keys with C++. I've heard of some system() commands for that but I haven't been able to get the exact syntax for it. Anybody willing to share the secret?
 
You're talking to a newbie programmer here. But that's newbie programmer, and not newbie computer user. I'm gonna need some explanations on the stuff you mentioned. Isn't there something like system("regedit etc.")?
 
Sure, you can use system() to run programs, but that's very inefficient, and you can't really edit system registry from command line - you have to use temporary .REG files and suchlike. The result is something very, very ugly. My conscience does not allow to tell you how to do such an awful thing :)

The page I linked to.. I guess it is not a very newbie-friendly..

Basically, to get access to the system registry API, you have to include the winreg.h file.

After that you use the RegOpenKeyEx() function to open a key. (Keys are the folder-like things in regedit). Since Windows API is totally retarded, you have to do this in a weird way. If you look at the sample code, you see that you have to define a HKEY variable and pass a reference to that to RegOpenKeyEx().

After you have opened a key, you can work with values inside using RegQueryValueEx() and RegSetValueEx().

You really have to chew through that article if you want to use the Windows API. Just keep thinking that the rest of the Windows API is even more horrible :)


What kind of C++ environment are you using? You may be able to use some more user-friendly libraries.
 
I'm using the Bloodshed Dev-C++ IDE 4.9.8.10 I have done some manual registry editing so I'm on somewhat familiar ground that way.
 
Status
Not open for further replies.
Back