I'm im troubles... Every time when i try run this i recive the ERROR 5 RegSetValueEx. When i change HKEY_LOCAL_MACHINE to HKEY_CURRENT_USER and Key adress it works. ¬¬ Some help please?
1 2 3 4 5 6 7 8 9 10 11
HKEY chave;
DWORD disp;
long r = RegCreateKeyEx(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"),0, NULL, 0, KEY_SET_VALUE, NULL, &chave, &disp);
printf("CREATE %d\n", r);
r = RegSetValueEx(chave,"xptu",0,REG_SZ,(PBYTE)"Gabriel",(DWORD)7);
printf("Set %d\n", r);
r = RegFlushKey(chave);
printf("Flush %d \n", r);
r = RegCloseKey(chave);
printf("Close %d \n\n\n \n", r);
fflush(stdout);
If this is windows 7/8 then it requires administrative privileges. I think you could add shortcuts to startup folder only for current user to launch programs at startup, this does not need admin privileges.,