Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

running an outside program??

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi
I would like to know the code to run another application from within my builder program.

eg: when I click on my compiled executable, I want it to run another program with 1 argument..

thanks
spabb(useless newbie:)
 
Do a search in this forum for ShellExecute. James P. Cottingham

I am the Unknown lead by the Unknowing.
I have done so much with so little
for so long that I am now qualified
to do anything with nothing.
 
you could also try a createprocess function
 
spabb,

Try this following chunk of code. I have not run this exact incarnation of this procedure, but it is extracted from a procedure that I use all the time. The code uses the CreateProcess() procedure from the Win32 API:

-----------------------------------------------------------

void __fastcall TformMain::MenuItemClick(TObject *Sender)
{
// Perform setup to spawn the external process... process.
STARTUPINFO StartupInfo;
ZeroMemory(&StartupInfo,sizeof(STARTUPINFO));
PROCESS_INFORMATION ProcessInfo;
StartupInfo.cb = sizeof(STARTUPINFO);
AnsiString s = &quot;<name of external program>&quot;;
//
// Spawn the program, then await its completion.
//
if( CreateProcess(s.c_str(),&quot;&quot;,NULL,NULL,TRUE,
NORMAL_PRIORITY_CLASS,NULL,NULL,&StartupInfo,&ProcessInfo) )
{
WaitForSingleObject( ProcessInfo.hProcess,INFINITE);
CloseHandle(ProcessInfo.hProcess);
CloseHandle(ProcessInfo.hThread);
//
}
else
ShowMessage((AnsiString)&quot;Unable to Find Program(s). &quot; + s.c_str());
}

--------------------------------------------------------

Hope this works for you!
Bob Gallaway
 
How about spawn? I don't remember the correct name or syntax... But search borland help for spawn.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top