Chat LIVE With Programming Experts! There Are 23 Online Right Now...

 

Code Snippets

  

C++ Source Code


Welcome to Dream.In.Code
Become a C++ Expert!

Join 244,258 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,276 people online right now. Registration is fast and FREE... Join Now!





Run exe after Windows Boot.

The goal of this snippet is to create a Path onto the registry so that every time you boot your Windows your exe file will start automatically.

Submitted By: nirvanarupali
Actions:
Rating:
Views: 1,922

Language: C++

Last Modified: October 8, 2007
Instructions: Use this snippet for any application you want.

Snippet


  1. /********************************************************************
  2. *
  3. *
  4. * The goal of this snippet is to create a Path onto the registry
  5. * so that everytime you boot your Windows it will start automatically.
  6. *
  7. *
  8. * You can use this registry entry in GUI or in Console applications.
  9. *
  10. *
  11. *
  12. *
  13. *************************************************************************/
  14.  
  15. #include <windows.h>
  16. #include <iostream>
  17.  
  18. using namespace std;
  19.  
  20.  
  21.  
  22. int main()
  23.  
  24.  
  25. {
  26.         cout << "Hello World";
  27.        
  28.  
  29. HKEY hKey;
  30.  
  31.  
  32.     // The path of your exe file. If you have a long path,
  33.     // change the number of elements in the array. 
  34.     unsigned char PathToFile[20]="C:\\hello2.exe";
  35.  
  36.    
  37.     // The directory of registry to be open.
  38.     RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion\\Run",0,
  39.     KEY_SET_VALUE,&hKey );
  40.  
  41.    
  42.     // Set the Value which is the directory of your exe file.
  43.     RegSetValueEx(hKey, "hello world",0,REG_SZ,PathToFile,sizeof(PathToFile));
  44.  
  45.    
  46.     //Close key.
  47.     RegCloseKey(hKey);
  48.  
  49.  
  50.  
  51.    return 0;
  52. }
  53.  

Copy & Paste


Comments


There are currently no comments for this snippet. Be the first to comment!

Add comment


You must be registered and logged on to </dream.in.code> to leave comments.





Live C++ Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month