What is the equivalent of Application.ProcessMessages, Application.Handle and Application.Terminated
Posted
by DavidB
on Stack Overflow
See other posts from Stack Overflow
or by DavidB
Published on 2010-03-24T14:12:49Z
Indexed on
2010/03/27
1:33 UTC
Read the original article
Hit count: 720
Hi, I am new to Writing Windows Service apps and having problems.
Written in Delphi, I have written a normal windows application to check and debug the major parts of the code and now have to convert it to an NT Service.
My code has to launch a windows application which I do using the following code.
function Run_Program : boolean;
var SEInfo : TShellExecuteInfo;
ExitCode : DWORD;
begin
Result := false;
FillChar(SEInfo, SizeOf(SEInfo),0);
SEInfo.cbSize :=SizeOf(TShellExecuteInfo);
With SEInfo do
begin
fMask := SEE_MASK_NOCLOSEPROCESS;
Wnd := **Application.Handle**;
lpFile := PChar(Exe_Prog);
lpParameters := PChar(Exe_Param);
nShow := SW_SHOWNORMAL;
end;
If ShellExecuteEx(@SEInfo) then
begin
repeat
Application.ProcessMessages;
GetExitCodeProcess(SEInfo.hProcess, ExitCode);
until (ExitCode <> STILL_ACTIVE) OR Application.Terminated OR NOT q1.fieldbyName('Delay').AsBoolean;
If ExitCode <> STILL_ACTIVE then Record_Event(Exe_Prog + ' completed ') else
Record_Event(Exe_Prog + ' activated ');
Result := true;
end
else Record_Event('Error Starting '+ Exe_Prog+ ' ');
end;
When this is put in the service app the compiler fails with 3 errors: Undeclared identifiers.. 1) Handle 2) ProcessMessages and 3) Terminated.
My question is.. are there equivalent procedures that can be used in a service application or should I approach the problem differently in a service application?
Any help would be appreciated
© Stack Overflow or respective owner