🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
5 messages
5 total messages Started by Wiebe Vos Sun, 19 Mar 2006 21:08
How to check status of app launched by ShellExecuteEx()
#4125
Author: Wiebe Vos
Date: Sun, 19 Mar 2006 21:08
8 lines
1164 bytes
I launch a (console) app via ShellExecuteEx() and use the hProcess
handle in SHELLEXECUTEINFO to terminate it later via
TerminateProcess().
How can I check in the meantime if the app is still running
and not been terminated by someone else?

Thanks in advance,
Wiebe 
Re: How to check status of app launched by ShellExecuteEx()
#4126
Author: Remy Lebeau (TeamB)
Date: Mon, 20 Mar 2006 01:15
24 lines
1691 bytes
"Wiebe Vos" <wiebe@foxware.nl> wrote in message
news:441dc83a@newsgroups.borland.com...

> I launch a (console) app via ShellExecuteEx()

You should be using CreateProcess() instead.  Don't use ShellExecute/Ex() to
lanch .exe files directly.  You should only use it to launch data files when
you don't know ahead of time which .exe will open them.

> and use the hProcess handle in SHELLEXECUTEINFO to
> terminate it later via TerminateProcess().

You should not be using TerminateProcess() at all, unless absolutely
necessary.  TerminateProcess() is a brute-force termination.  Why are you
not letting the process terminate itself normally?

> How can I check in the meantime if the app is still running
> and not been terminated by someone else?

Use GetExitCodeProcess().


Gambit
Re: How to check status of app launched by ShellExecuteEx()
#4128
Author: Wiebe Vos
Date: Mon, 20 Mar 2006 18:26
50 lines
2540 bytes
Thanks Remy,

> You should be using CreateProcess() instead.
   I did, works fine now.
   However, how can I hide the DOS window?
   (Probably via STARTUPINFO, but I can't figure out how)

> You should not be using TerminateProcess()
    I have to I think. It is a console app with no windowhandle to go after.

> Why are you not letting the process terminate itself normally?
    It does not. It's a 3rd party app that terminates itself only if
    unaltered information appears after a certain period of time)

> Use GetExitCodeProcess().
   That does it.

Wiebe

"Remy Lebeau (TeamB)" <no.spam@no.spam.com> schreef in bericht 
news:441e0231$1@newsgroups.borland.com...
>
> "Wiebe Vos" <wiebe@foxware.nl> wrote in message
> news:441dc83a@newsgroups.borland.com...
>
>> I launch a (console) app via ShellExecuteEx()
>
> You should be using CreateProcess() instead.  Don't use ShellExecute/Ex() 
> to
> lanch .exe files directly.  You should only use it to launch data files 
> when
> you don't know ahead of time which .exe will open them.
>
>> and use the hProcess handle in SHELLEXECUTEINFO to
>> terminate it later via TerminateProcess().
>
> You should not be using TerminateProcess() at all, unless absolutely
> necessary.  TerminateProcess() is a brute-force termination.  Why are you
> not letting the process terminate itself normally?
>
>> How can I check in the meantime if the app is still running
>> and not been terminated by someone else?
>
> Use GetExitCodeProcess().
>
>
> Gambit
>
>
> 
Re: How to check status of app launched by ShellExecuteEx()
#4130
Author: Remy Lebeau (TeamB)
Date: Mon, 20 Mar 2006 18:58
12 lines
1306 bytes
"Wiebe Vos" <wiebe@foxware.nl> wrote in message
news:441ef3fd@newsgroups.borland.com...

>    However, how can I hide the DOS window?
>    (Probably via STARTUPINFO, but I can't figure out how)

Set the dwFlags member to include the STARTF_USESHOWWINDOW flag, and then
set the wShowWindow member to SW_HIDE.


Gambit
Re: How to check status of app launched by ShellExecuteEx()
#4131
Author: Wiebe Vos
Date: Mon, 20 Mar 2006 19:42
3 lines
1009 bytes
Execellent.

Wiebe 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads