Snippet
/********************************************************************
*
*
* The goal of this snippet is to create a Path onto the registry
* so that everytime you boot your Windows it will start automatically.
*
*
* You can use this registry entry in GUI or in Console applications.
*
*
*
*
*************************************************************************/
#include <windows.h>
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World";
HKEY hKey;
// The path of your exe file. If you have a long path,
// change the number of elements in the array.
unsigned char PathToFile[20]="C:\\hello2.exe";
// The directory of registry to be open.
RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion\\Run",0,
KEY_SET_VALUE,&hKey );
// Set the Value which is the directory of your exe file.
RegSetValueEx(hKey, "hello world",0,REG_SZ,PathToFile,sizeof(PathToFile));
//Close key.
RegCloseKey(hKey);
return 0;
}
Copy & Paste
|