Adding a key to the windows registry [solved: admin rights needed]

Hi everyone,

I know that there are other topics about my issue in the forum, but I can't figure out why my code isn't working.

I'm trying to add a key to the windows registry:

1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>
#include <windows.h>

using namespace std;

int main(){
    int value;
    HKEY hKey;

    value = RegCreateKeyEx(HKEY_CLASSES_ROOT, "\\*\\shell\\Open with Notepad", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, NULL );
    cout << value;
}



Can someone helpme with this? What am I doing wrong?
Thanks.
Last edited on
\\*\\?

You should have a hostname or IP address in there.
Thanks for the answer.

Really? Because if i create the key manually, and export it, i get:

1
2
3
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\Open with Notepad]



--------------

Edit: Just tested it with the hostname, it's not working either...
Last edited on
Well, what error code do you get back?
value = 5

Meaning that I have no access or permission to modify the registry....
I realized that I should not use Run button inside my IDE, but run the exe generated. It works now, thanks kbm.
Topic archived. No new replies allowed.