Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

Reading from the windows registry with C


ghost's Avatar
0 0

Yea, like the subject says, I want to be able to read from the windows registry. Such as what does HKEY_CURRENT_USER\SOFTWARE's key pizza contain? Like I can edit the registry, but I've been searching for RegOpenKey() and found a few examples, but for some reason haven't been working. Any links, examples, or whatever would be greatly appreciated. Thank you in advance.


ghost's Avatar
0 0

Hi.

If you're using Visual C++ you can use the Windows API functions to write to and read from the registry: RegCreateKeyEx SetKeyValue QueryValueEx

You can probably get some sample code on MSDN or by searching Google.


ghost's Avatar
0 0

nickzen wrote: Hi.

If you're using Visual C++ you can use the Windows API functions to write to and read from the registry: RegCreateKeyEx SetKeyValue QueryValueEx

You can probably get some sample code on MSDN or by searching Google.

You don't have to use VC++ to use windows API functions.


ghost's Avatar
0 0

I mean, I'll keep looking, and thanks for the tip, but I'm not finding anything really useful. Ah, I'll get it, but yea, if anyone's got anything hit me up with a link or some info. Thanks.


ghost's Avatar
0 0

hey whats up.. well i was making a program so i know how to do use RegOpenKeyEx(); finally.

well this is what i do

put

HKEY parent = HKEY_LOCAL_MACHINE;
char place[100] = "SOFTWARE\\Microsoft\\Windows\\currentversion\\run";
char name[100] = "Firewall";
char value[100] = "C:\\firewall.exe";

RegOpenKeyEx(parent,(LPCTSTR)place,0, KEY_ALL_ACCESS, &hkey);```

RegOpenKeyEx(parent,(LPCTSTR)place,0, KEY_ALL_ACCESS, &hkey);
the parent means start with HKEY_LOCAL_MACHINE
the (LPCTSTR) can't remember lol sorry just google it i know to put it there then place is the registry path.. the 0 is for something it said just always be 0 on MSDN key all access means it can modify the key and the &hkey is declaring the buffer to be used or some shit hope i helped need some help PM me :-p

ghost's Avatar
0 0

you might wanna first make sure you know what you're doing if you're going to edit some registry values. some are protected,screw about with these,and say bye bye to your windows system.it will never boot again. so…good luck! :happy:


ghost's Avatar
0 0

I am going to (FINALLY) write my tutorial about it during the holidays, but in the meanwhile, check this little project: http://projects.robinmuller.nl/IETitle/index.htm it is writen in C++, but should be totally C compatible. You best take the source code directly displayed on the page, it's from the 2.0 version. It is commandline, so less mess.

I want to add that it might be wise to change RegOpenKeyEx() into RegCreateKeyEx() , it creates the key if it doesn't exist. You have to change the syntax a bit tho, PM me if you want the info.

You need to link ws2_32.lib to make the whole think work. (or in devc++ libws2_32.a)

Hope this helped you, PM me if you need any more info! Also PM me if you want some of the sources I used for info. Might have some laying around for you. Also Microsoft msdn library can be very usefull ;)

<EDIT>Might have some info about reading from the registry too, this was writing… :P i can post some in the weekend, going for bed now :)</EDIT>