#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    1
    Rep Power
    0

    Running 3 dependent applications from inside VC++ : system command does not help


    Hi All,

    I am new to VC++ and I will be really grateful for your help.
    My problem is that I want to execute 3 applications one after the other using system command in VC++ code.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Eg. My VC++ code should have something like:
    system("c:\\work\\scheduling-application.exe");
    Sleep(2);
    system("c:\\work\\receiver-applicaiton.exe");
    Sleep(10);
    system("c:\\work\\sender-applicaiton.exe");
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Now the problem is that the above code does not run for me.
    scheduling-application starts and also receiver-applicaiton starts but sender-applicaiton does not start. Rather the system hangs and I have to restart. No helpful error message just the standard error message pop-up saying "Microsoft Windows needs to close this program"

    BUT if I try to run these 3 applications from outside VC++ code, they run perfectly. These 3 applications should be executed strictly in the order as shown in above code.

    Can anyone please suggest what am I missing? How I should overcome this problem?

    Thanks a lot!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2002
    Location
    Flint, MI
    Posts
    328
    Rep Power
    13
    Some programs are not amenable to being launched this way. imapxfer from U Washington was this way for me.

    If System() isn't working, you might look at popen, which may work. There's also a Windows API command specifically for launching a program (besides System(), which is bad to use anyway). It's been two years since I did anything with the Windows API though, and I generally avoided calling external programs anyway.
    Clay Dowling
    Lazarus Notes
    Articles and commentary on web development
    http://www.lazarusid.com/notes/
  4. #3
  5. Titles are useless ;)
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    Germanski West
    Posts
    216
    Rep Power
    15
    Dont know if it helps you, cause dont know what you want to do!

    API-Func:
    HINSTANCE ShellExecute(
    HWND hwnd, // handle to parent window
    LPCTSTR lpOperation, // pointer to string that specifies operation to perform
    LPCTSTR lpFile, // pointer to filename or folder name string
    LPCTSTR lpParameters, // pointer to string that specifies executable-file parameters
    LPCTSTR lpDirectory, // pointer to string that specifies default directory
    INT nShowCmd // whether file is shown when opened
    );

    or

    WINSHELLAPI BOOL WINAPI ShellExecuteEx(
    LPSHELLEXECUTEINFO lpExecInfo // pointer to SHELLEXECUTEINFO structure
    );

    See Reference for descriptions!
    Allows you to open (run) programs, files, hyperlinks! Or to print!
    Last edited by MaierMan; February 10th, 2003 at 09:15 AM.

IMN logo majestic logo threadwatch logo seochat tools logo