🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #4126

Re: How to check status of app launched by ShellExecuteEx()

#4126
From: 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
Technical Details
Message-ID: <441e0231$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news4.google.com!newshub.sdsu.edu!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <441dc83a@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,380f727a338f7f53
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <441dc83a@newsgroups.borland.com>
Subject: Re: How to check status of app launched by ShellExecuteEx() 
Date: Sun, 19 Mar 2006 17:15:22 -0800
Lines: 27
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 68.69.17.41
Message-ID: <441e0231$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1142817329 68.69.17.41 (19 Mar 2006 17:15:29 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news4.google.com!newshub.sdsu.edu!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail