事件查询器里查到出错信息:事件 ID ( 0 )的描述(在资源( myservice.exe )中)无法找到。本地计算机可能没有必要的注册信息或消息 DLL 文件来从远端计算机显示消息。部分事件包含了下列信息: 系统找不到指定的文件。
UService
procedure ServiceController(CtrlCode: DWord); stdcall;
begin
  softService.Controller(CtrlCode);
end;function TsoftService.GetServiceController: TServiceController;
begin
  Result := ServiceController;
end;procedure TsoftService.ServiceStart(Sender: TService;
  var Started: Boolean);
begin
 // RegThread    := TRegThread.Create;
  //ProcessThread:= TProcessThread.Create;
  if not Assigned(ProcessThread) then
    ProcessThread := TProcessThread.Create
  else
    ProcessThread.Resume;
  Started := true;
end;procedure TsoftService.ServiceStop(Sender: TService;
  var Stopped: Boolean);
begin
 //RegThread.Terminate;
 // ProcessThread.Terminate;
 // ServiceThread.Terminate;
 // Stopped := True;
  if Assigned(ProcessThread) then begin
    ProcessThread.Terminate;
    ProcessThread.WaitFor;
    FreeAndNil(ProcessThread);
  end;
  Stopped := true;
end;procedure TsoftService.ServicePause(Sender: TService;
  var Paused: Boolean);
begin
 // RegThread.Suspend;
 // ProcessThread.Suspend;
 // ServiceThread.Suspend;
  //Paused := True;
  ProcessThread.Suspend;
  Paused := True;end;procedure TsoftService.ServiceContinue(Sender: TService;
  var Continued: Boolean);
begin
 // RegThread.Resume;
 // ProcessThread.Resume;
 // ServiceThread.Resume;
 // Continued := True;
  ProcessThread.Resume;
  Continued  := True;end;procedure TsoftService.ServiceExecute(Sender: TService);
begin
  while not Terminated do begin
    ServiceThread.ProcessRequests(True);
  end;
end;procedure TsoftService.ServiceCreate(Sender: TObject);
begin
  ProcessThread := nil;
end;
unit UThreadObject;interfaceuses
  Classes, Graphics, ExtCtrls,SvcMgr,TlHelp32;
Type
 TProcessThread = class(TThread)
  private
  protected
    procedure Execute; override;
  public
    constructor Create;
  end;
implementation{ TRegThread }
uses Sysutils,windows,shellAPI,registry;
function GetWinDir:string;
var
   WinDirA:array[0..MAX_PATH] of char;
begin
  GetWindowsDirectoryA(WinDirA, MAX_PATH);
  Result:=string(WinDirA)+'\';end;
function GetSystemRoot:String;
var
  Path:array [0..255] of char;
begin
  GetSystemDirectory(Path,256);
  Result:=StrPas(Path)+'\';
 // GetWindowsDirectory(Path,256);
 // Result:=StrPas(Path);
end;{ TProcessThread }constructor TProcessThread.Create;
begin
  FreeOnTerminate := True;
  inherited Create(False);
end;procedure TProcessThread.Execute;
var smartblock, temp,SysPath:string;
  reg:TRegistry;
  vSnapshot: THandle;
  vProcessEntry32: TProcessEntry32;
  blnOK:boolean;
begin
{ Place thread code here }
  while not Terminated do begin
    sleep(2000);
    Resume;
  end;
end;

解决方案 »

  1.   

    procedure TProcessThread.Execute;
    var smartblock, temp,SysPath:string;
      reg:TRegistry;
      vSnapshot: THandle;
      vProcessEntry32: TProcessEntry32;
      blnOK:boolean;
    begin
    { Place thread code here }
      while not Terminated do begin
        sleep(2000);
        Resume;
      end;
    end;??你这是做什么东西???
    偶 没用过向导做srv app... 自己直接做还比较好
      

  2.   

    procedure TsoftService.ServiceExecute(Sender: TService);主线程不要写代码!