Thread: opening a program outside of C++

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    6

    opening a program outside of C++

    I need to know how to start a program and get it running outside of my c++ program. I am making a file and need to open it with a different program. I am using dev c++ 4.9.8.0 on Win XP home. I also need to know how you can tell the computer that you have inputed certain keys using c++ and running those keys in the other program. Is it possible or should I just get the user to press the keys himself?

  2. #2
    Registered User Nova_Collision's Avatar
    Join Date
    Feb 2003
    Posts
    40
    CreateProcess() will do it. It has a crapload of parameters, tho. Either look it up in the MSDN help or try this:

    Code:
    STARTUPINFO si;
    PROCESS_INFORMATION pi;
    memset(&pi, 0, sizeof(pi));
    memset(&si, 0, sizeof(si));
    si.cb = sizeof(si);
    int res = CreateProcess("path+executable.exe -parameters", 0, 0, 0, 0, 0, 0, 0, &si, &pi);
    If CreateProcess returns 0 (as in res = 0), then the process creation failed. This is very basic as I only recently figured this out. I'd recommend that you read up on CreateProcess().
    When in doubt, empty your magazine - Murphy's Laws Of Combat #7

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Opening a file from the a console program
    By pritin in forum C++ Programming
    Replies: 20
    Last Post: 09-02-2005, 11:30 AM
  2. Opening program code
    By Shaniac in forum C++ Programming
    Replies: 9
    Last Post: 07-14-2005, 10:55 PM
  3. Replies: 3
    Last Post: 01-14-2003, 10:34 PM
  4. Opening a file from within a program
    By face_master in forum C++ Programming
    Replies: 7
    Last Post: 09-08-2001, 11:06 AM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM