搞了一个上午了,没有结果,翻遍了CSDN也没找到答案。
启动是显示“本地计算机上的服务启动有停止了。一些服务自动停止....”
事件查看器中的错误是“事件 ID ( 0 )的描述(在资源( CreateFile )中)无法找到。本地计算机可能没有必要的注册信息或消息 DLL 文件来从远程计算机显示消息。您可能可以使用 /AUXSOURCE= 标识来检索词描述;查看帮助和支持以了解详细信息。下列信息是事件的一部分: Service failed on start: 尚未调用 CoInitialize。.”,在服务及线程中都加了initialization
begin
CoInitialize(nil);
end;
也不行,与代码如下:
procedure TCreateLFile.ServiceStart(Sender: TService;
var Started: Boolean);
begin
MainConn.ConnectionString:='......';//TADO连接对象
MainConn.Connected:=True;
CXML:=TGenerateRss.Create(MainConn);
CXML.Resume;
Started:=True;
end;procedure TCreateFile.ServiceStop(Sender: TService;
var Stopped: Boolean);
begin
CXML.Terminate;
Stopped:=True;
end;procedure TCreateFile.ServicePause(Sender: TService;
var Paused: Boolean);
begin
CXML.Suspend;
Paused:=True;
end;procedure TCreateFile.ServiceContinue(Sender: TService;
var Continued: Boolean);
begin
CXML.Resume;
Continued:=True;
end;procedure TCreateFile.ServiceShutdown(Sender: TService);
begin
if Assigned(CXML) then
begin
// The TService must WaitFor the thread to finish (and free it)
// otherwise the thread is simply killed when the TService ends.
CXML.Terminate;
CXML.WaitFor;
FreeAndNil(CXML);
end;
end;
//-------------------------------
procedure TGenerate.Execute;
procedure CreateXMLFile;
begin
...........读取数据库操作,在一般程序中已通过
end;
const SecBetweenRuns = 60;
var Count: Integer;
begin
{ Place thread code here }
Count:=0;
while not Terminated do // loop around until we should stop
begin
Inc(Count);
if Count >= SecBetweenRuns then
begin
Count := 0;
{ place your service code here }
{ this is where the action happens }
CreateXMLFile;
end;
Sleep(1000);
end;
end;constructor TGenerate.Create(paraConn:TADOConnection);
// Create the thread Suspended so that properties can be set before resuming the thread.
begin
tConn:=paraConn;
tConn.Connected:=True;
qryDoc.Connection:=tConn;
qryClass.Connection:=tConn;
FreeOnTerminate := True;
inherited Create(True);
end;
启动是显示“本地计算机上的服务启动有停止了。一些服务自动停止....”
事件查看器中的错误是“事件 ID ( 0 )的描述(在资源( CreateFile )中)无法找到。本地计算机可能没有必要的注册信息或消息 DLL 文件来从远程计算机显示消息。您可能可以使用 /AUXSOURCE= 标识来检索词描述;查看帮助和支持以了解详细信息。下列信息是事件的一部分: Service failed on start: 尚未调用 CoInitialize。.”,在服务及线程中都加了initialization
begin
CoInitialize(nil);
end;
也不行,与代码如下:
procedure TCreateLFile.ServiceStart(Sender: TService;
var Started: Boolean);
begin
MainConn.ConnectionString:='......';//TADO连接对象
MainConn.Connected:=True;
CXML:=TGenerateRss.Create(MainConn);
CXML.Resume;
Started:=True;
end;procedure TCreateFile.ServiceStop(Sender: TService;
var Stopped: Boolean);
begin
CXML.Terminate;
Stopped:=True;
end;procedure TCreateFile.ServicePause(Sender: TService;
var Paused: Boolean);
begin
CXML.Suspend;
Paused:=True;
end;procedure TCreateFile.ServiceContinue(Sender: TService;
var Continued: Boolean);
begin
CXML.Resume;
Continued:=True;
end;procedure TCreateFile.ServiceShutdown(Sender: TService);
begin
if Assigned(CXML) then
begin
// The TService must WaitFor the thread to finish (and free it)
// otherwise the thread is simply killed when the TService ends.
CXML.Terminate;
CXML.WaitFor;
FreeAndNil(CXML);
end;
end;
//-------------------------------
procedure TGenerate.Execute;
procedure CreateXMLFile;
begin
...........读取数据库操作,在一般程序中已通过
end;
const SecBetweenRuns = 60;
var Count: Integer;
begin
{ Place thread code here }
Count:=0;
while not Terminated do // loop around until we should stop
begin
Inc(Count);
if Count >= SecBetweenRuns then
begin
Count := 0;
{ place your service code here }
{ this is where the action happens }
CreateXMLFile;
end;
Sleep(1000);
end;
end;constructor TGenerate.Create(paraConn:TADOConnection);
// Create the thread Suspended so that properties can be set before resuming the thread.
begin
tConn:=paraConn;
tConn.Connected:=True;
qryDoc.Connection:=tConn;
qryClass.Connection:=tConn;
FreeOnTerminate := True;
inherited Create(True);
end;
解决方案 »
- 将下面的批处理文件不写成bat文件,在delphi内部写如何处理?
- 怎样对其他单元隐藏类或禁止创建实例?
- delphiTquery组件执行sql insert语句问题
- 小弟最近最近学fastreport总找不到头 帮啊 ~~
- 新手问问题,我想实现监测网络上一台机器是否在线,请问怎么实现?谢谢
- 为什么没有.DLL文件
- Dll问题,麻烦
- 我爱Delphi之一:Delphi开发环境快捷键全集(需要您的加入)
- 无法删除了,该怎么办?
- 我的问题大家看看
- 我发现最近Delphi版来了不少穿小内裤的Java 粉丝
- 多用户系统:同时有多个用户操作一个数据表,怎么来控制当有一个人编辑操作时,别人就不可以操作呢?我记得好像是把表锁死吧
tConn.Connected:=True;
CoInitialize(nil);
tConn.Connected:=True;
后是同样问题,启动时显示“本地计算机上的服务启动又停止了。一些服务自动停止....”
// Create the thread Suspended so that properties can be set before resuming the thread.
begin
tConn:=paraConn;这东东能这样赋吗?