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