Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Help Using GetExitCodeProcess...

306 views
Skip to first unread message

Jake Richards

unread,
Apr 16, 2001, 11:35:29 PM4/16/01
to
Hello:
(I know you all are getting tired of hearing from me... but)
I am trying to use GetExitCodeProcess to determine if a process is still
running or has exited(and what exit code it had). I use this to call Notepad.exe:

ZeroMemory( &StartupInfo, sizeof( StartupInfo ) );
StartupInfo.cb = sizeof(STARTUPINFO);

CreateProcess( NULL,
commandline,
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
&StartupInfo,
&ProcessInformation);

I then click a button later on to call this (while notepad is running)

GetExitCodeProcess(ProcessInformation.hProcess,&exit_status);

and it bombs out(returns 0) and GetLastError returns 6. I don't know what the 6
means, anyone? Am I calling this right(either function) Thanks!

Jan Bares

unread,
Apr 17, 2001, 2:13:14 AM4/17/01
to
error 6 means ERROR_INVALID_HANDLE. Probably CreateProcess failed?

Regards Jan

--

Jan Bares
(remove no.spam from my email address)
JPCAD Graphics Engine developer, surf to http://www.antek.cz


"Jake Richards" <jake.r...@us.bosch.com> wrote in message
news:cd5801c0c6ef$73119770$19ef2ecf@tkmsftngxa01...

Jake Richards

unread,
Apr 17, 2001, 11:46:18 AM4/17/01
to
When i call createprocess, Notepad pops up on my screen, so it seems to be
working. But maybe i'm just not setting up my processinfo structure right? Or
not calling createprocess right? Thanks!

Jake

Regards Jan

--

GetExitCodeProcess(ProcessInformation.hProcess,&exit_status);

.

Franek

unread,
Apr 17, 2001, 10:11:14 PM4/17/01
to
1. Null out *all* parameters (including ProcessInfo)
2. Check the god damn returns in all API functions you call.
3. You can look at what the error is if you have a number by using the Error Lookup
tool--which can be accessed either from the IDE's Tools menu, or from the VC's group in
your Start/Programs/[whatever your Visual Studio called this shortcut]


Finally: maybe you Close(d)Handle of your process before checking its return code? If you
closed this handle, you're not gonna be able to use it after that, and indeed it becomes
invalid.

Vadim Melnik

unread,
Apr 18, 2001, 8:04:21 AM4/18/01
to
BTW there is cool ERR pseudo register in VC++ debugger that displays the
last error code for the current thread. It retrieves the same value as
calling GetLastError function. Use it in conjunction with the ",hr"; e.g. in
"Quick watch" or other watch window type "err,hr". I believe it will be
useful for steps 2/3 described by Franek.


"Franek" <einst...@worldnet.att.net> wrote in message
news:3ADCF9A1...@worldnet.att.net...

0 new messages