CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    May 1999
    Posts
    327

    how can I execute a program from another program


    I have 2 files; one called calc.exe and the other plot.exe. The file
    calc.exe creates data and sends it to a file while plot.exe reads the
    data from the file and plots it.

    How can I execute plot.exe while running calc.exe.



  2. #2
    Join Date
    Apr 1999
    Location
    Italy
    Posts
    9

    Re: how can I execute a program from another program

    get a look at the "exec" and at the "spawn" functions family.

    Alessandro

    Why do we hide from the police, Dad?
    Because we use vi, Son. They use emacs.

  3. #3
    Join Date
    Apr 1999
    Location
    Chennai, India
    Posts
    48

    Re: how can I execute a program from another program

    hi,
    if u use NT/95/98 use CreateProcess as shown below !

    void Runanother ( LPSTR lpszFilename)
    {
    STARTUPINFO si;
    PROCESS_INFORMATION pi;
    ZeroMemory( &si, sizeof(si) );
    si.cb = sizeof(si); // Start the child process.

    if( !CreateProcess( NULL, // No module name (use command line).
    lpszFilename, // Command line.
    NULL, // Process handle not inheritable.
    NULL, // Thread handle not inheritable.
    FALSE, // Set handle inheritance to FALSE.
    0, // No creation flags.
    NULL, // Use parent’s environment block.
    NULL, // Use parent’s starting directory.
    &si, // Pointer to STARTUPINFO structure.
    &pi ) // Pointer to PROCESS_INFORMATION structure.
    )
    {
    Error ("CreateProcess failed.");
    return;
    }

    // Wait until child process exits.
    WaitForSingleObject( pi.hProcess, INFINITE );
    // Close process and thread handles.
    CloseHandle( pi.hProcess );
    CloseHandle( pi.hThread );
    }

    enjoy the code !



  4. #4
    Join Date
    May 1999
    Posts
    327

    Re: how can I execute a program from another program

    I don't understand how to send the filename. The
    LPSTR command doesn't make sense. Can you
    please, please, please, show me how to call this
    function. Let's say I want to call the program
    c:\windows\calc.exe

    ** RunAnother ( LPSTR lpszFilename) **




  5. #5
    Join Date
    May 1999
    Posts
    16

    Re: how can I execute a program from another program

    Call like this -> RunAnother ( "c:\windows\calc.exe" );


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured