Click to See Complete Forum and Search --> : how can I execute a program from another program


Danielle Harvey
April 29th, 1999, 12:02 PM
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.

Alessandro
April 29th, 1999, 12:27 PM
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.

rajasekar.s
April 29th, 1999, 12:51 PM
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 !

Danielle Harvey
April 29th, 1999, 02:40 PM
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) **

dineshsv
May 3rd, 1999, 02:06 AM
Call like this -> RunAnother ( "c:\windows\calc.exe" );