Registry Editing

This is a discussion on Registry Editing within the Windows Programming forums, part of the Platform Specific Boards category; I've searched every thread in the board and hit MSDN for this for hours, but I still cannot solve my ...

Registry Editing

I've searched every thread in the board and hit MSDN for this for hours, but I still cannot solve my problem. I am aiming to create a registry key in the Run dir, or simply to make my program run each time on boot. To do this, I need to RegCreateKeyEx, then to RegSetValueEx, to set the value of this key, however none of this is working. This is the little I have so far :

As you see, it's a bunch of nothing. I tried many combinations, but I can't get the BYTE to work in RegSetValueEx, and the RegCreateKeyEx doesn't want to work. As well as that, I'm not using my handle to my key, HKEY HandleKey, but a pointer to it, HandleKey2... If anyone could enlighten me, I'd be very grateful.
Thanks,
Korhedron

Few things...try to open the key instead of re-creating it...if you are opening 1 key, you need 1 handle - not 2...you open a key with 1 handle, then close on a NULL-handle and try to use it??...Always check your errors!!!

1 The "Run" key already exists...you are just opening it and adding a value for your app.
2 You pass that pointer to get a handle to the key you are opening. Without that you cant address the open key.
3 Yeah...just use a standard C type cast - (const BYTE *)...but I like to use the C++ casts whenver I code - preference!

RegCreateKeyEx() returns ERROR_SUCCESS if it works, otherwise it returns the reason for failing, you should retrieve and examine this status. I suspect it will tell you that the last parameter should be the address of a variable to return it's action code in, and not NULL.