I ask at this forum a little while back about starting another application from my program and ShellExecute was suggested. Now ShellExecute worked great. My original question was about starting the program but not waiting until that program exited. Now I have a new problem. I want to wait until the application exits but I do not want it to open a new window.
My application operates on files and has no input other than a command file and no output other than a MessageBox. The console I think one guy called it doesn't show up at all. That is exactly what I want.
ShellExecute returns before the other application finishes but if I use system the console pops up and shows all of the output from that application. I am not trying to hide what I am doing but having the console pop up and do its thing is not really what I want.
I have read the API documentation about ShellExecute and ShellExecuteEX but I don't understand how to make them not return until the other application is done. How do I run another application and wait on it without using system?
Will anyone help me with this and maybe help me write a function I can use for all three features?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
So all Google hands out is fake pictures of the olsen twins. Perhaps Google is only offering the better alternative!
>That answer is also unhelpful.
Ok, I'll do the rest. Having a page that mostly answered the question, I looked for keywords that would improve my search to find better sites and I spotted "ShellExecuteEx process handle WaitForSingleObject". Googling brought up websites with plenty of C++ examples. This is from the first link:
Q: How do I start a program, and halt execution of my current program, till that program exits?
A: You start the program using ShellExecuteEx and use WaitForSingleObject on the process handle.
If it helps or convinces someone who knows how to help, I was looking at the wait functions. If that is right then I could not figure out how to use the functions together or which one to use.
>The console I think one guy called it doesn't show up at all
Whither a program is a console or a GUI program is controlled by the program being launched, not the program doing the launching. If a program is compiled as a GUI then that is what it shall be.
>How do I run another application and wait on it without using system?
I googled "ShellExecute wait for command" and found it in the first link. If that answer isn't good enough, reading will suggest better search words.
Do you remember in Star Trek how they could ask the computer anything and it instantly knew the answer no matter how unknowable it was? That computer has already been built and it's name is Google! It will help you get your programming episodes over in 52 minutes too. Try Googling for "the answer to life the universe and everything" sometime and see what you get.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
"Whither a program is a console or a GUI program..."
That may be and right or wrong I don't want the console visible. I don't care if the console, GUI or purple pygmy. Using ShellExecute I can make the console invisible and with system it is visible. It pops up in the way.
I tried your google search and the first link came up as Delphi. I scarcely know C so Delphi is out. I looked at the site anyway and the example for waiting seems somewhat clear but does not work here. The third link and the next few links are about software or other programming languages. Just because you can search google and say "the answer is google" doesn't make the answers google turns up helpful to a new programmer.
I have read the book and seen the movie so I know the answer. That answer is also unhelpful.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I ask at this forum a little while back about starting another application from my program and ShellExecute was suggested. Now ShellExecute worked great. My original question was about starting the program but not waiting until that program exited. Now I have a new problem. I want to wait until the application exits but I do not want it to open a new window.
My application operates on files and has no input other than a command file and no output other than a MessageBox. The console I think one guy called it doesn't show up at all. That is exactly what I want.
ShellExecute returns before the other application finishes but if I use system the console pops up and shows all of the output from that application. I am not trying to hide what I am doing but having the console pop up and do its thing is not really what I want.
I have read the API documentation about ShellExecute and ShellExecuteEX but I don't understand how to make them not return until the other application is done. How do I run another application and wait on it without using system?
Will anyone help me with this and maybe help me write a function I can use for all three features?
So all Google hands out is fake pictures of the olsen twins. Perhaps Google is only offering the better alternative!
>That answer is also unhelpful.
Ok, I'll do the rest. Having a page that mostly answered the question, I looked for keywords that would improve my search to find better sites and I spotted "ShellExecuteEx process handle WaitForSingleObject". Googling brought up websites with plenty of C++ examples. This is from the first link:
Q: How do I start a program, and halt execution of my current program, till that program exits?
A: You start the program using ShellExecuteEx and use WaitForSingleObject on the process handle.
SHELLEXECUTEINFO ShExecInfo = {0};
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = NULL;
ShExecInfo.lpFile = "c:\MyProgram.exe";
ShExecInfo.lpParameters = "";
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_SHOW;
ShExecInfo.hInstApp = NULL;
ShellExecuteEx(&ShExecInfo);
WaitForSingleObject(ShExecInfo.hProcess,INFINITE);
If it helps or convinces someone who knows how to help, I was looking at the wait functions. If that is right then I could not figure out how to use the functions together or which one to use.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/wait_functions.asp
>The console I think one guy called it doesn't show up at all
Whither a program is a console or a GUI program is controlled by the program being launched, not the program doing the launching. If a program is compiled as a GUI then that is what it shall be.
>How do I run another application and wait on it without using system?
I googled "ShellExecute wait for command" and found it in the first link. If that answer isn't good enough, reading will suggest better search words.
Do you remember in Star Trek how they could ask the computer anything and it instantly knew the answer no matter how unknowable it was? That computer has already been built and it's name is Google! It will help you get your programming episodes over in 52 minutes too. Try Googling for "the answer to life the universe and everything" sometime and see what you get.
"Whither a program is a console or a GUI program..."
That may be and right or wrong I don't want the console visible. I don't care if the console, GUI or purple pygmy. Using ShellExecute I can make the console invisible and with system it is visible. It pops up in the way.
I tried your google search and the first link came up as Delphi. I scarcely know C so Delphi is out. I looked at the site anyway and the example for waiting seems somewhat clear but does not work here. The third link and the next few links are about software or other programming languages. Just because you can search google and say "the answer is google" doesn't make the answers google turns up helpful to a new programmer.
I have read the book and seen the movie so I know the answer. That answer is also unhelpful.
well chris you are bad wrong. i know of at least one question that google can not answer.
"where can i find authentic nude images of the olsen twins?"
is signing this even necessary? ^_^ i think not.