Dan*_*llo 26 delphi debugging service windows-services
有没有办法用Delphi完全调试Windows服务?
jas*_*nny 25
您可以使用Colin Wilson的NT低级实用程序中的 unitDebugService.pas (页面已经消失,可在返回机器中使用)
然后在DPR中:
begin
if (paramCount > 0) and (SameText(ParamStr(1), '-DEBUG')) then
begin
FreeAndNil (Application);
Application := TDebugServiceApplication.Create(nil);
end;
//... the rest of the normal DPR code
end.
Run Code Online (Sandbox Code Playgroud)
通过这种方式,您可以在Delphi中运行调试(通过设置项目调试器参数),使用EXE作为服务,或者使用-DEBUG交换机从命令行运行,以及.
Sco*_*ens 19
这实际上非常简单.只需使用标准的DEBUG编译器指令即可将服务作为控制台应用程序而非服务启动.
program MyServiceApp;
{$ifdef DEBUG}
{$APPTYPE CONSOLE}
{$endif}
uses
System.SysUtils,
Run Code Online (Sandbox Code Playgroud)
[..]
begin
{$ifdef DEBUG}
try
// In debug mode the server acts as a console application.
WriteLn('MyServiceApp DEBUG mode. Press enter to exit.');
// Create the TService descendant manually.
ServerContainer1 := TServerContainer.Create(nil);
// Simulate service start.
ServerContainer1.ServiceStart(ServerContainer1, MyDummyBoolean);
// Keep the console box running (ServerContainer1 code runs in the background)
ReadLn;
// On exit, destroy the service object.
FreeAndNil(ServerContainer1);
except
on E: Exception do
begin
Writeln(E.ClassName, ': ', E.Message);
WriteLn('Press enter to exit.');
ReadLn;
end;
end;
{$else}
// Run as a true windows service (release).
if not Application.DelayInitialize or Application.Installing then
Application.Initialize;
Application.CreateForm(TServerContainer, ServerContainer1);
Application.Run;
{$endif}
end.
Run Code Online (Sandbox Code Playgroud)
小智 14
使用运行 - >附加进行处理.这样,您可以调试服务,而无需对其代码进行任何更改.唯一棘手的部分可能是调试服务启动代码,因为附加可能需要一些时间,并且启动必须在30秒内完成(尽管您可以调整Windows以允许更长的时间).您可以使用延迟(睡眠...)来允许您及时附加,或者如果您只是需要查看会发生什么,您可以使用OutputDebugString()打印到调试输出(使用Delphi事件视图查看它).
是的,有: 调试服务:一种简单的方法
你用Delphi创建服务吗?那么也许你每次都会以耗时的方式对启动,重启,查杀和附加到服务流程应用程序感到恼火.好吧,有补救措施.
你不需要这样做.而是将Delphi作为SYSTEM应用程序运行,并对服务代码进行一些小的调整.
我试过这个,但只出现带有汇编代码的cpu窗口.
那你只应该解决这个问题.
基本上,要调试Win2服务,有几种方法:
如果由于某种原因在开始调试后只有您的服务的CPU视图 - 这意味着Delphi的调试器无法找到您的服务的调试信息.这是一个不同的问题,你应该搜索它的解决方案.
通常,您需要这样做:
| 归档时间: |
|
| 查看次数: |
21158 次 |
| 最近记录: |