Aug 11, 2014 at 7:17am UTC
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 Aug 11, 2014 at 5:28pm UTC
Aug 11, 2014 at 10:57am UTC
\\*\\
?
You should have a hostname or IP address in there.
Aug 11, 2014 at 12:06pm UTC
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 Aug 11, 2014 at 12:13pm UTC
Aug 11, 2014 at 12:33pm UTC
Well, what error code do you get back?
Aug 11, 2014 at 5:26pm UTC
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.