Click to See Complete Forum and Search --> : how to get the return value of main


SunCore
September 17th, 2005, 05:41 PM
hi,

I have a program that i wrote, and compiled.
and i need to get the return value of it's main function, using other program, that i'm gon'a write later.

i use windows xp sp2.

is it possible?


thanks in advance.

Siddhartha
September 17th, 2005, 05:59 PM
I have a program that i wrote, and compiled.
and i need to get the return value of it's main function, using other program, that i'm gon'a write later.

i use windows xp sp2.

is it possible? Yes, you would use Win API GetExitCodeProcess (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/getexitcodeprocess.asp).

To see how to invoke a process programmatically, read -


FAQ: How can I start a process? (http://www.codeguru.com/forum/showthread.php?t=302501)
FAQ: How can I wait till a process ends? (http://www.codeguru.com/forum/showthread.php?t=312451)
You would use the Process Handle returned by the creation API in a call to GetExitCodeProcess to get the return value (after waiting for the process to end).

Siddhartha
September 17th, 2005, 06:00 PM
[ redirected ]

Regards,
Siddhartha