akif
akif

Reputation: 12324

Return value of process

How can I get the return value of a process? Basically I'm **ShellExecute()**ing a .NET process from a DLL (in C++). The process does its task, but now I want to know whether it succeeded or failed. How to do that in WinAPI or MFC?

Upvotes: 1

Views: 842

Answers (3)

HX_unbanned
HX_unbanned

Reputation: 597

ShellExecute() in its native is 16-bit call, so it is not intended to give feedback / callback althought you can saerch thread / process / memory adress ( if you locate usable memory space ) and its flags ( if there would be no such a thing as bloody flags, WinAPI (32-bit) would be much simpatic than it is now ). To provide full feedback, you can try extended version or CreateProcess() function with is pure 32-bit function. Unfourtinately I cannot give you any detailed info about flags / Lparameters and other API parameters.

Besides, mainly all executive function/procedures/methods retur booleans, so you always can start with [if..then] statement as return provider.

Opps, while i was writing this, already three answers were made.

Upvotes: 0

Jon Skeet
Jon Skeet

Reputation: 1499800

Use ShellExecuteEx instead so you can get a handle to the process which was launched. You should then be able to use GetExitCodeProcess to obtain the exit code.

(I've left this answer here despite the similar one from MSalters, as I suspect you're using ShellExecute deliberately to get the shell behaviour instead of explicitly creating the process.)

Upvotes: 2

MSalters
MSalters

Reputation: 179779

Use CreateProcess(). keep the process handle and call GetExitCodeProcess() when the process handle becomes signalled.

Upvotes: 5

Related Questions