前面帖子的一个系统服务脚本:
//这是重点
//根据需要修改服务名称 "myservice",以及服务程序 'c:\winnt\system32\myservice.exe';
function NextButtonClick(CurPageID: Integer): Boolean;
begin
case CurPageID of
wpReady: //安装开始前才开始添加
begin
if IsServiceInstalled('myservice') = false then
begin
if InstallService('c:\winnt\system32\myservice.exe','myservice','my service','my service is doing usefull things',SERVICE_WIN32_OWN_PROCESS,SERVICE_AUTO_START) = true then
begin
StartService('myservice');
StopService('myservice');
// after stopping a service you should wait some seconds before removing
RemoveService('myservice');
// otherwise removing can fail
end
end
else if IsServiceRunning('myservice') then
begin
MsgBox('myservice is running',mbInformation, MB_OK);
end;
end;
end;
Result := True;
end;
最近有找到一个脚本,它的系统服务安装函数内容是:
function InstallService(FileName, ServiceName, DisplayName, Description : string;ServiceType,StartType :cardinal;szDepends:string) : boolean;
var
hSCM : HANDLE;
hService: HANDLE;
begin
hSCM := OpenServiceManager();
Result := false;
if hSCM <> 0 then begin
hService := CreateService(hSCM,ServiceName,DisplayName,SERVICE_ALL_ACCESS,ServiceType,StartType,SERVICE_ERROR_NORMAL,FileName,'',0,szDepends,'','');
if hService <> 0 then begin
Result := true;
// Win2K & WinXP supports aditional description text for services
if Description<> '' then
RegWriteStringValue(HKLM,'System\CurrentControlSet\Services\' + ServiceName,'Description',Description);
CloseServiceHandle(hService)
end;
CloseServiceHandle(hSCM)
end
end;
请问老虎版主,如果要使用,上面该怎么修改?
附件:
系统服务配置.zip (5 K) 下载次数:1