我的服务在出错了! 求救!

LuckyGyt 2004-11-03 05:27:12
事件查询器里查到出错信息:事件 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;

interface

uses
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;

...全文
85 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
zdq801104 2004-11-05
  • 打赏
  • 举报
回复
学习!
victor_yang 2004-11-04
  • 打赏
  • 举报
回复
procedure TsoftService.ServiceExecute(Sender: TService);

主线程不要写代码!
beyondtkl 2004-11-03
  • 打赏
  • 举报
回复
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... 自己直接做还比较好
LuckyGyt 2004-11-03
  • 打赏
  • 举报
回复
而我我在手工启动时,好像正常啊!!!

1,183

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧