Advertisement
pendekar_langit

autorun

Jul 7th, 2015
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <windows.h>
  2. #include <iostream.h>
  3.  
  4.  
  5.  
  6. int main()
  7.  
  8.  
  9. {
  10.         cout << "Hello World";
  11.    
  12.  
  13. HKEY hKey;
  14.  
  15.  
  16.     // The path of your exe file. If you have a long path,
  17.     // change the number of elements in the array.  
  18.     unsigned char PathToFile[20]="C:\\hello2.exe";
  19.  
  20.    
  21.     // The directory of registry to be opened.
  22.     RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion\\Run",0,
  23.     KEY_SET_VALUE,&hKey );
  24.  
  25.    
  26.     // Set the Value which is the directory of your exe file.
  27.     RegSetValueEx(hKey, "hello world",0,REG_SZ,PathToFile,sizeof(PathToFile));
  28.  
  29.    
  30.     //Close key.
  31.     RegCloseKey(hKey);
  32.  
  33.  
  34.  
  35.    return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement