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

SHELL Error Code

Status
Not open for further replies.

sflau

Programmer
Oct 18, 2001
87
0
0
HK
I am using VB 6.0 and calling the SHELL function:

SHELL(runsth.exe)

But I am not sure whether the program "runsth.exe" will have retunr code. Because I want to know if the process "runsth.exe" failed, will it returns error or not.

Any one can tell me how to capture the return code from "runsth.exe", please?

Thank you.
 
Here is the further information:
Actually, I run the following coding:

strCmd = "runsth.exe"

lngExecOK = Shell(strCmd)
lProcessHandle = OpenProcess(&H100000, True, lngExecOK)
lReturnValue = WaitForSingleObject(lProcessHandle, 10000)
CloseHandle lProcessHandle

I want to know if the runsth.exe have return code, will it retunr to "lReturnValue"? Actually, I always get "0".
 
lReturnValue will the result of WaitForSingleObject, not the exit code of the process. You need to call GetExitCodeProcess once the wait is over.
 
I have two VB programs provided by a vendor that call ExitProcess to return a code. I also have a test program that calls these two executables in succession that utilizes exactly the above set of steps to get the return codes.

When I recompiled all three of these on my Win2K professional workstation, I get a "The file is invalid" handle when calling GetExitCodeProcess in the test program. This happens for both programs. I have Visual Studio 6, SP 4. Any idea what's going wrong?
 
Sorry, I hit submit before I proofread. The error message is "The handle is invalid", and it's generated at the GetExitCodeProcess statement.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top