i have an exe file (a command line program) that i want to open up when a user types in go or something. where would i put the exe file and how should i write the code?
thnx
i have an exe file (a command line program) that i want to open up when a user types in go or something. where would i put the exe file and how should i write the code?
thnx
For windows try:
Have to include windows.h for that. Another way without including windows.h is:Code:WinExec("C:\\prog.exe",SW_SHOW);
Have to include stdlib.h for that.Code:system("C:\\prog.exe");
Last edited by jmd15; 09-26-2005 at 06:27 PM.
Trinity: "Neo... nobody has ever done this before."
Neo: "That's why it's going to work."
c9915ec6c1f3b876ddf38514adbb94f0
That should be "C:\\prog.exe" in jmd15's examples.
You could put the exe in the same directory as your program's exe. Then you wouldn't have to specify a path to it, you just pass the exe name.
thnx guys it worked!
Win32 SDK FAQ - Processes: How can I start a process?
>> Note that 'WinExec()' is provided only for compatibility with 16-bit Windows and should not be used any longer* 'system()' family (C run-time library - ANSI ('system()') or Win NT ('_wsystem()'))
* '_exec()' family (C run-time library - Win 95, Win NT)
* '_spawn()' family (C run-time library - Win 95, Win NT)
* 'WinExec()' (Win32 API)
* 'ShellExecute()' (Shell API)
* 'ShellExecuteEx()' (Shell API)
* 'CreateProcess()' (Win32 API)
* 'CreateProcessAsUser()' (Win32 API)
* 'CreateProcessWithLogonW()' (Win32 API)
And system is probably less prefered, as the alternate _exec/_spawn are there for portability, no real need to fire up a command shell to start up a process.
thnx for the help guts it works.