在Delphi中做了一些不同的服务之后,我意识到TService
缺乏一些它应该有一个服务应用程序,如日志,异常处理,并在注册表中的“描述”属性需要的东西。是否有可能让TService的后代发布我自己的属性?
我想知道是否可以制作我自己的服务外壳,例如TJDService
,它是从TService
继承的,但还有一些额外的东西,例如在对象检查器中显示的“描述”属性。我可以制作我自己的服务外壳吗?我知道我可以创建自己的“默认项目”,它继承自TService
,但包括我的所有代码以及任何新项目。
当创建一个新的服务,它应该是这样的:
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Classes, Vcl.SvcMgr,
JDServices;
type
TJDService1 = class(TJDService)
private
public
function GetServiceController: TServiceController; override;
end;
var
JDService1: TJDService1;
implementation
{$R *.DFM}
procedure ServiceController(CtrlCode: DWord); stdcall;
begin
JDService1.Controller(CtrlCode);
end;
function TJDService1.GetServiceController: TServiceController;
begin
Result := ServiceController;
end;
end.
同一个典型的服务,但使用我的TJDService
,而不是仅仅TService
。
您正在寻找RegisterCustomModule - http://docwiki.embarcadero.com/VCL/en/DesignIntf.RegisterCustomModule – OnTheFly 2012-02-12 19:52:49
“Embarcadero Technologies目前没有任何其他信息,请使用讨论页面帮助我们记录此主题!“并且人们想知道为什么其他人会抱怨缺少delphi文档:P – 2012-02-12 19:56:56
使用designtime包中的RegisterCustomModule让Object Inspector知道服务类中的任何发布的属性,如果你不需要,那么你可以忽略RegisterCustomModule – 2012-02-12 19:58:08