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

program inside of a program??

Status
Not open for further replies.

GUJUm0deL

Programmer
Jan 16, 2001
3,676
US
Is it possiable to open another C++ program inside of another?? I know some1 who has a C++ program and they wanna be able to open another C++ program inside that one...
example -- like in DOS, you can open program.exe inside of DOS... I have not failed; I merely found 100,000 different ways of not succeding...
 
there should be many functions. The simpliest is
system("xxx.exe"); John Fill
1c.bmp


ivfmd@mail.md
 
So in the first C++ program, where does the 'system(*.exe)' go?? Towards the end?? In other words, how does the person actually call the other program to run inside the first one?? I have not failed; I merely found 100,000 different ways of not succeding...
 
instead of system(*.exe) put system("*.exe") John Fill
1c.bmp


ivfmd@mail.md
 
ok, but where in the first program would that go?? in the bottom at the top?? Does anything else have to called to bring up the second program?? Just add: system("*.exe") and thas it?? I have not failed; I merely found 100,000 different ways of not succeding...
 
you should call one by one programs by theirs names
system("xx.exe");
system("xxx.exe");
system("c:\\xxx\\yyyy.exe"); John Fill
1c.bmp


ivfmd@mail.md
 
Use the API call Create Process. You will need Winbase.h and kernel32.lib if you are not inside a Visual C++.

BOOL CreateProcess(
LPCTSTR pApplicationName,// name of executable module
LPTSTR lpCommandLine, // command line string
LPSECURITY_ATTRIBUTES lpProcessAttributes, // SD
LPSECURITY_ATTRIBUTES lpThreadAttributes, // SD
BOOL bInheritHandles, // handle inheritance option
DWORD dwCreationFlags, // creation flags
LPVOID lpEnvironment, // new environment block
LPCTSTR lpCurrentDirectory, // current directory name
LPSTARTUPINFO lpStartupInfo, // startup information
LPPROCESS_INFORMATION lpProcessInformation // process information
);

I Know it is a little bit lengthy, but it works like a charm, and you get also control of the created process(exe).

Hope this helps,
s-)

Blessed is he who in the name of justice and good will, shepards the week through the valley of darknees...
 
Thanx alot guys, it helped my friend out alot... I have not failed; I merely found 100,000 different ways of not succeding...
 
I want to do something similar. I have an executable that I do not have access to source that I want to run within a windows program and get the output from it (mainly stderr). I had it working using non-visual c++ using popen, however that won't work now that I'm coding a windows app. I tried using the section "Creating a Child Process with Redirected Input and Output" in the Win32 SDK, but I'm new to Vis C++ and couldn't get it to work. Can somebody please help me/walk me through this?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top