I'm trying to write code which can add some software to registry. Here is my code :
int main()
{
HKEY hkey;
LONG RegOpenResult;
const char path[] = "C:\\Users\\Adrian\\Documents\\Visual Studio 2015\\Projects\\TcpServer\\x64\\Debug\\TcpServer.exe";
RegOpenResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", 0, KEY_ALL_ACCESS, &hkey);
RegSetValue(hkey,L"Server",REG_SZ, L"C:\\Users\\Adrian\\Documents\\Visual Studio 2015\\Projects\\TcpServer\\x64\\Debug\\TcpServer.exe",strlen(path)+1);
RegCloseKey(hkey);
return 0;
}
I can compile and run it, but it dosen't create a new key in SOFTWARE\Microsoft\Windows\CurrentVersion\Run
I also tried what i found here: Add Application to Startup (Registry). But i have the same problem. I can compile and run it but no key is added.
Has anyone an idea?
Aucun commentaire:
Enregistrer un commentaire