我是新編寫Windows Service應用程序並遇到問題。什麼是Application.ProcessMessages,Application.Handle和Application.Terminated在Windows服務應用程序中的等價物?
在Delphi中寫的,我寫了一個正常的Windows應用程序來檢查和調試代碼的主要部分,現在必須將其轉換爲NT服務。
我的代碼必須啓動一個Windows應用程序,我使用下面的代碼。
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;
當這樣放置在服務應用程序編譯器將失敗,3個錯誤:未聲明的標識符.. 1)手柄 2)ProcessMessages和 3)終止。
我的問題是..是否有可以在服務應用程序中使用的等效過程,還是應該在服務應用程序中以不同的方式解決問題?
任何幫助,將不勝感激
+1,所有*非常*好點。 – mghie 2010-03-28 07:31:00