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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

system () or CreateProcess() ???

Status
Not open for further replies.

alsd

Technical User
Feb 23, 2000
4
0
0
HK
Hello all,<br>
<br>
I want to execute an program from within the application I am developing. Is using the API call CreateProcess () better (eg faster) than calling system()? Or the other around?<br>
<br>
Thanks for any tips or info.<br>
<br>
-al<br>

 
I guess it kind of depends on what you want to do. I have used both; I use CreateProcess() if I am going to execute another program and want to wait for it to complete before going on. I use system() to run a quick DOS-type command like &quot;type&quot; or &quot;dir&quot;. <br>
<br>
Depending on what you want to do, either would work, but reading a bit between the lines I would hazard a guess and say that you may want to use CreateProcess().<br>
<br>
Good Luck! <p>Pat Gleason<br><a href=mailto:gleason@megsinet.net>gleason@megsinet.net</a><br><a href= > </a><br>
 
Pat, Al --<br>
<br>
Another option would be the ShellExecute() function, which also has the ability to open a document in it's default viewer. Very useful for displaying a HTML file and you don't care what browser they have installed.<br>
<br>
Chip H.<br>

 
Good point. Again, I guess it comes down to what kind of program you want to run, or what exactly you're trying to do. <p>Pat Gleason<br><a href=mailto:gleason@megsinet.net>gleason@megsinet.net</a><br><a href= > </a><br>
 
Yes as mentioned earlier. It depends on the requirement. CreateProcess() function creates a thread and run the program parallely to the main program . So if your main program needs some data from the program which you ran from CreateProcess(). Then it is good to use the CreateProcess(). While System() function is used to run the commands mainly. It is totally independent of the program from which you are calling System() .Although you can get data from System() function also. But is doesn't create another thread.<br>
Does it answer your question ?<br>
Thanx<br>
Siddhartha Singh<br>
<A HREF="mailto:ssingh@aztecsoft.com">ssingh@aztecsoft.com</A>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top