How can I get the return value of a program that I launched from my program?
How can I get the return value of a program that I launched from my program?
How are you calling the program from within a program?
popen(), system(), fork()/exec() ?
http://faq.cprogramming.com/cgi-bin/...&id=1043284392
Which of these are you using to run your sub-program?
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
echo %errorlevel%
Originally Posted by brewbuck:
Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.
I dunno, something imaginative like reading the manual page for CreateProcess(), which has a handy "see also" section.
Obviously, this is the place to look for related functions, and gosh, there it is.
http://msdn.microsoft.com/library/de...odeprocess.asp
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Does this mean thatCode:BOOL WINAPI GetExitCodeProcess( HANDLE hProcess, LPDWORD lpExitCode );
is proper and valid too?Code:DWORD main()
Also, what happens when I try to get the exit code on a
program?Code:void main()
Thanks for link , kinda stupid question thought I suppose, seeing how I have USED THE STUPID FUNC BEFORE! (Seeing the function prototype again brought it back.)
Last edited by Queatrix; 10-10-2006 at 11:19 AM.
Why do you think you're not supposed to use void main()?Also, what happens when I try to get the exit code on a
program?Code:void main()
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
Yea, that's what I figured, but still, what would happen? Would the function fail? Or would it just return 0x00000000?
It's undefined!
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
True, but a really old compiler like turbo C++ or MSVC++6.0 would accept it as being a valid statement. Nowdays, most people put int main ( void )
There is a saying on IRC channels...
TIAS!
(Try it and see!)
Nope.Originally Posted by Dev-C++
Why is Win32 sooo... hung up on DWORD!?
> DWORD main()
int main is the portable answer.
It's just that a DWORD is capable of storing all possible integer values on that particular platform. I guess win32 GUI programs which begin with winmain() also return a DWORD as the exit status.
Besides, very few operating system shells can cope with process exit status values which exceed 8 bits, it isn't that much of a deal.
> Also, what happens when I try to get the exit code on a
<clint>Well punk, do you feel lucky</clint>
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.