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

How can I use the ExitProcess function?

547 views
Skip to first unread message

Daniel Engler

unread,
Jan 26, 1999, 3:00:00 AM1/26/99
to
Hello
Does anybody know how to use ExitProcess function? Maybe anybody can show me
a short example? What about GetExitCodeProcess and GetExitCodeThread do I
have do use this functions?
Thank you.
Daniel

mailto:in...@ligonet.ch

Bogdan Pop

unread,
Jan 26, 1999, 3:00:00 AM1/26/99
to
There is an exemple for runninig a process and wait it's end (I run this on NT4)

The initialisation code for lpstartupinfo can be replace with a 'ZeroMemory'
call (I think)

var lpProcessInformation: TProcessInformation;
lpStartupInfo : TStartupInfo;
r:integer;

with lpStartupInfo do
begin
cb:=0;
lpReserved:=nil;
lpDesktop:=nil;
lpTitle:=nil;
dwX:=0;
dwY:=0;
dwXSize:=0;
dwYSize:=0;
dwXCountChars:=0;
dwYCountChars:=0;
dwFillAttribute:=0;
dwFlags:=STARTF_USESHOWWINDOW;
wShowWindow:=SW_NORMAL;
cbReserved2:=0;
lpReserved2:=nil;;
hStdInput:=0;
hStdOutput:=0;
hStdError:=0;
end;

if
CreateProcess('aprogram.exe','',nil,nil,false,0,nil,nil,lpStartupInfo,lpProcessInformation)

then
repeat
GetExitCodeProcess(lpProcessInformation.hprocess,r);
application.processmessages;
until Application.Terminated or (r <> STILL_ACTIVE);

Use ExitProcess to terminate a process and use the GetExitCodeProcess function
to retrieve the process's exit value

Steve Schafer (TeamB)

unread,
Jan 26, 1999, 3:00:00 AM1/26/99
to
On Tue, 26 Jan 1999 09:31:09 +0100, "Daniel Engler" <eng...@ibm.net>
wrote:

>Does anybody know how to use ExitProcess function?

Yes, but why do you want to use it? In Delphi, you can just call

Halt(ExitCode);

for the same effect. ExitCode can be any integer value. But, it's
usually not a good idea to terminate your program this way, unless
you're sure that all necessary cleanup operations have been performed.

-Steve


Kim Robert Blix

unread,
Jan 27, 1999, 3:00:00 AM1/27/99
to
Bogdan Pop wrote in message

>var lpProcessInformation: TProcessInformation;
> lpStartupInfo : TStartupInfo;
> r:integer;

[SNIP]
> GetExitCodeProcess(lpProcessInformation.hprocess,r);


I get an error at this point.

(85) "Types of actual and formal var parameters must be identical".

Ideas?

Kim Robert Blix

Kim Robert Blix

unread,
Jan 27, 1999, 3:00:00 AM1/27/99
to
>>var lpProcessInformation: TProcessInformation;
>> lpStartupInfo : TStartupInfo;
>> r:integer;


>> GetExitCodeProcess(lpProcessInformation.hprocess,r);


>I get an error at this point.
>
>(85) "Types of actual and formal var parameters must be identical".


allow me to rephrase that. I do get the error, but it compiles ok when I
change "r" to doubleword rather than use integer. BUT, it still hangs when
the program I execute generate a second window. There has got to be away
around this problem.. I've been searching ofr solutions but so far -nothing-
has
worked, and Im getting a little depressed here :)

Take care,

Kim Robert Blix

Bogdan Pop

unread,
Jan 28, 1999, 3:00:00 AM1/28/99
to
Hi,

Actually I used that code an it works, on NT4. Pay attention on the parameters
for CreateProcess, it may be some difference in the specifications of
application name and parameters.
When you say it hangs what do u mean, you don't have acces to the second window
at all? I ask you that because u cannot have acces to the main program until u
close the second window.

See U :)
Bogdan

Bogdan Pop

unread,
Jan 28, 1999, 3:00:00 AM1/28/99
to
There was something wrong in the previous answer. Actually u have the control
for the main window too, only if u use application.processmessages .
0 new messages