I am new to writing Windows Service applications and problems.
Written in Delphi, I wrote a regular Windows application for checking and debugging the main parts of the code, and now I have to convert it to an NT service.
My code should start the Windows application that I am using 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 placed in the utility application, the compiler fails with 3 errors: Undeclared identifiers .. 1) Handle 2) Message processing and 3) Ends.
My question is: are there equivalent procedures that can be used in the service application, or should I have a different approach to the problem in the service application?
Any help would be appreciated