Skip to main content
gamedev.net
🔒 Locked

opening a program from inside another,need help

Started by CiscoKid Jan 20, 2001 at 10:17 PM 3 replies 350+ views
Original Post
CiscoKid
CiscoKid
quick question hopefully... im writting in C++ a Win32 console application using the MS compiler. is there a commad to call another program complete with a command line? thanks, ciscokid Edited by - ciscokid on January 20, 2001 11:18:48 PM
yo yo ma
yo yo ma
i think you can do something like this
  
system("cd directoryProgramIsIn");
system("programName commandline");

the system function may or may not be called exaclty that but someone else might know the name of it or you could look it up in the help files of MSVC

"Yo yo ma"
-Kramer
"Yo yo ma" -Kramer
AlexM
AlexM
correct me if I''m wrong, but I think you can use windows ShellExecute in your console, just don''t specify an HWND for error messages

HINSTANCE ShellExecute(
HWND hwnd,
LPCTSTR lpOperation,
LPCTSTR lpFile,
LPCTSTR lpParameters,
LPCTSTR lpDirectory,
INT nShowCmd
);

the problem would be ending this program when you want to. If you are shelling a windows application, I think you can use FindWindow() to get the main app window, if you know the window name

HWND FindWindow(
LPCTSTR lpClassName, // pointer to class name
LPCTSTR lpWindowName // pointer to window name
);

and call SendMessage(hwnd,WM_QUIT or WM_CLOSE,0,0).

Regards,
Alex.
CiscoKid
CiscoKid
ok got it to work, thanks for the help

the ciscokid

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.