Thread: starting a .exe from code

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    411

    starting a .exe from code

    What sort of function/statement do i use to start up a .exe from inside my code?

  2. #2
    Registered User ski6ski's Avatar
    Join Date
    Aug 2001
    Posts
    133
    Here is some code to mess with. There are other ways, like spawn, but this should give you an idea....
    Code:
    #include <stdlib.h>
    #include <iostream.h>
    #include <conio.h>
    
    int main(void)
    {
    	int choice;
    
    	cout<<"Press the number for the choice of program you want to run."<<endl
    		<<endl<<endl;
    	cout<<"1. Windows Calculator"<<endl
    		<<"2. Windows Notepad"<<endl
    		<<"3. Windows Paintbrush"<<endl
    		<<"4. Windows Solitaire"<<endl
    		<<"5. EXIT"<<endl;
    
    	while(choice != 5){
    	choice = getch();
    
    	switch (choice)
    	{
    	case '1':
    		{
    		(void)system("C:\\WINDOWS\\CALC.EXE");
    		break;
    		}
    	case '2':
    		{
    		(void)system("C:\\WINDOWS\\NOTEPAD.EXE");
    		break;
    		}
    	case '3':
    		{
    		(void)system("C:\\WINDOWS\\PBRUSH.EXE");
    		break;
    		}
    	case '4':
    		{
    		(void)system("C:\\WINDOWS\\SOL.EXE");
    		break;
    		}
    	case '5':
    		{
    			exit(EXIT_SUCCESS);
    		}
    
    	}
    	}
    
    	return 0;
    }
    C++ Is Powerful
    I use C++
    There fore I am Powerful

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 03-21-2006, 07:52 AM
  2. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  3. True ASM vs. Fake ASM ????
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 04-02-2003, 04:28 AM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. Replies: 4
    Last Post: 01-16-2002, 12:04 AM