山
山沟穷女生念不起大学
Unregistered / Unconfirmed
GUEST, unregistred user!
我刚学习安装系统服务
下面是我看了网上文章后学习写的代码:
Project1.dpr
////////////////////////////////////////////////////////////
program Project1;
uses
SvcMgr,
Unit1 in 'Unit1.pas' {Service1: TService};
{$R *.RES}
begin
Peizhi.WinServerView := 'Delphi服务演示程序';
Peizhi.WinServerName := 'DelphiService';
SvcMgr.Application.Initialize;
Service1 := TService1.CreateNew(SvcMgr.Application,0);
SvcMgr.Application.Run;
end.
Unit1.pas
/////////////////////////////////////////////////////////////////
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, SvcMgr, Dialogs;
type
SerInfo = record
Regqidong: Boolean;
WinXpSer: Boolean;
WinServerView:String;
WinServerName:String;
WinServerText:String;
end;
type
TService1 = class(TService)
protected
procedure Start(Sender: TService; var Started: Boolean);
procedure Stop(Sender: TService; var Stopped: Boolean);
public
function GetServiceController: TServiceController; override;
constructor CreateNew(AOwner: TComponent; Dummy: Integer = 0); override;
end;
var
Service1: TService1;
Peizhi: SerInfo;
implementation
{$R *.DFM}
constructor TService1.CreateNew(AOwner: TComponent; Dummy: Integer);
begin
inherited;
AllowPause := False;
Interactive := True;
DisplayName := Peizhi.WinServerView;
Name := Peizhi.WinServerName;
OnStart := Start;
OnStop := Stop;
end;
procedure ServiceController(CtrlCode: DWord); stdcall;
begin
Service1.Controller(CtrlCode);
end;
function TService1.GetServiceController: TServiceController;
begin
Result := ServiceController;
end;
procedure TService1.Start(Sender: TService; var Started: Boolean);
begin
Started := True;
end;
procedure TService1.Stop(Sender: TService; var Stopped: Boolean);
begin
Stopped := True;
end;
end.
我想请各位老师,帮我完善:
1.怎么才能够让软件一运行就自动安装服务?我是在命令行中输入Project1.exe /install /silent的,这样很麻烦,我想让软件运行的时候自己安装.
2.安装成功不会弹出 Service installed successfully 窗口.
3.如果已经安装系统服务了,第二次开机软件会自动识别,就不用再安装了.
4.如何处理不同的系统 98 2000 XP 2003等等
十分感谢!
下面是我看了网上文章后学习写的代码:
Project1.dpr
////////////////////////////////////////////////////////////
program Project1;
uses
SvcMgr,
Unit1 in 'Unit1.pas' {Service1: TService};
{$R *.RES}
begin
Peizhi.WinServerView := 'Delphi服务演示程序';
Peizhi.WinServerName := 'DelphiService';
SvcMgr.Application.Initialize;
Service1 := TService1.CreateNew(SvcMgr.Application,0);
SvcMgr.Application.Run;
end.
Unit1.pas
/////////////////////////////////////////////////////////////////
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, SvcMgr, Dialogs;
type
SerInfo = record
Regqidong: Boolean;
WinXpSer: Boolean;
WinServerView:String;
WinServerName:String;
WinServerText:String;
end;
type
TService1 = class(TService)
protected
procedure Start(Sender: TService; var Started: Boolean);
procedure Stop(Sender: TService; var Stopped: Boolean);
public
function GetServiceController: TServiceController; override;
constructor CreateNew(AOwner: TComponent; Dummy: Integer = 0); override;
end;
var
Service1: TService1;
Peizhi: SerInfo;
implementation
{$R *.DFM}
constructor TService1.CreateNew(AOwner: TComponent; Dummy: Integer);
begin
inherited;
AllowPause := False;
Interactive := True;
DisplayName := Peizhi.WinServerView;
Name := Peizhi.WinServerName;
OnStart := Start;
OnStop := Stop;
end;
procedure ServiceController(CtrlCode: DWord); stdcall;
begin
Service1.Controller(CtrlCode);
end;
function TService1.GetServiceController: TServiceController;
begin
Result := ServiceController;
end;
procedure TService1.Start(Sender: TService; var Started: Boolean);
begin
Started := True;
end;
procedure TService1.Stop(Sender: TService; var Stopped: Boolean);
begin
Stopped := True;
end;
end.
我想请各位老师,帮我完善:
1.怎么才能够让软件一运行就自动安装服务?我是在命令行中输入Project1.exe /install /silent的,这样很麻烦,我想让软件运行的时候自己安装.
2.安装成功不会弹出 Service installed successfully 窗口.
3.如果已经安装系统服务了,第二次开机软件会自动识别,就不用再安装了.
4.如何处理不同的系统 98 2000 XP 2003等等
十分感谢!