|
@@ -23,8 +23,10 @@ Resourcestring
|
|
SErrNoControlContext = 'Not handling Control message without control context: (%d %d %d).';
|
|
SErrNoControlContext = 'Not handling Control message without control context: (%d %d %d).';
|
|
SControlCodeReceived = 'Control message received: (%d %d %d).';
|
|
SControlCodeReceived = 'Control message received: (%d %d %d).';
|
|
|
|
|
|
|
|
+{$IF SIZEOF(CHAR)=1}
|
|
function StartServiceCtrlDispatcher(lpServiceStartTable: LPSERVICE_TABLE_ENTRY): BOOL; stdcall; external 'advapi32.dll' name 'StartServiceCtrlDispatcherA';
|
|
function StartServiceCtrlDispatcher(lpServiceStartTable: LPSERVICE_TABLE_ENTRY): BOOL; stdcall; external 'advapi32.dll' name 'StartServiceCtrlDispatcherA';
|
|
function RegisterServiceCtrlHandlerEx(lpServiceName: LPCSTR;lpHandlerProc: LPHANDLER_FUNCTION_EX; lpContext: LPVOID): SERVICE_STATUS_HANDLE; stdcall;external 'advapi32.dll' name 'RegisterServiceCtrlHandlerExA';
|
|
function RegisterServiceCtrlHandlerEx(lpServiceName: LPCSTR;lpHandlerProc: LPHANDLER_FUNCTION_EX; lpContext: LPVOID): SERVICE_STATUS_HANDLE; stdcall;external 'advapi32.dll' name 'RegisterServiceCtrlHandlerExA';
|
|
|
|
+{$ENDIF}
|
|
function SetServiceStatus(hServiceStatus: SERVICE_STATUS_HANDLE; const lpServiceStatus: SERVICE_STATUS): BOOL; stdcall; external 'advapi32.dll' name 'SetServiceStatus';
|
|
function SetServiceStatus(hServiceStatus: SERVICE_STATUS_HANDLE; const lpServiceStatus: SERVICE_STATUS): BOOL; stdcall; external 'advapi32.dll' name 'SetServiceStatus';
|
|
|
|
|
|
{ ---------------------------------------------------------------------
|
|
{ ---------------------------------------------------------------------
|
|
@@ -40,11 +42,11 @@ begin
|
|
Application.Log(etError,Format(SerrNoControlContext,[dwControl,dwEventType,ptrint(lpEventData)]));
|
|
Application.Log(etError,Format(SerrNoControlContext,[dwControl,dwEventType,ptrint(lpEventData)]));
|
|
end;
|
|
end;
|
|
|
|
|
|
-Procedure ServiceMainEntry(Argc : DWord; Args : PAnsiChar); stdcall;
|
|
|
|
|
|
+Procedure ServiceMainEntry(Argc : DWord; Args : PChar); stdcall;
|
|
|
|
|
|
begin
|
|
begin
|
|
If Assigned(Application) then
|
|
If Assigned(Application) then
|
|
- Application.Main(Argc,PPAnsiChar(Args));
|
|
|
|
|
|
+ Application.Main(Argc,PPChar(Args));
|
|
{$ifdef svcdebug}Debuglog('Main end');{$endif}
|
|
{$ifdef svcdebug}Debuglog('Main end');{$endif}
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -150,11 +152,11 @@ const
|
|
|
|
|
|
// Careful, result of this function must be freed !!
|
|
// Careful, result of this function must be freed !!
|
|
|
|
|
|
-Function GetDependencies(D : TDependencies) : PAnsiChar;
|
|
|
|
|
|
+Function GetDependencies(D : TDependencies) : PChar;
|
|
|
|
|
|
var
|
|
var
|
|
I,L : Integer;
|
|
I,L : Integer;
|
|
- P : PAnsiChar;
|
|
|
|
|
|
+ P : PChar;
|
|
|
|
|
|
begin
|
|
begin
|
|
Result:=Nil;
|
|
Result:=Nil;
|
|
@@ -170,10 +172,10 @@ begin
|
|
begin
|
|
begin
|
|
if D[i].IsGroup then
|
|
if D[i].IsGroup then
|
|
begin
|
|
begin
|
|
- P^:=AnsiChar(SC_GROUP_IDENTIFIER);
|
|
|
|
|
|
+ P^:=Char(SC_GROUP_IDENTIFIER);
|
|
Inc(P);
|
|
Inc(P);
|
|
end;
|
|
end;
|
|
- P:=StrECopy(P,PAnsiChar(D[i].Name));
|
|
|
|
|
|
+ P:=StrECopy(P,PChar(D[i].Name));
|
|
Inc(P);
|
|
Inc(P);
|
|
end;
|
|
end;
|
|
P^:=#0;
|
|
P^:=#0;
|
|
@@ -184,13 +186,13 @@ Procedure TCustomDaemonApplication.SysInstallDaemon(Daemon : TCustomDaemon);
|
|
|
|
|
|
Var
|
|
Var
|
|
SM,SV: SC_HANDLE;
|
|
SM,SV: SC_HANDLE;
|
|
- SD,N,DN,E,LG,UN,UP : AnsiString;
|
|
|
|
|
|
+ SD,N,DN,E,LG,UN,UP : String;
|
|
DD : TDaemonDef;
|
|
DD : TDaemonDef;
|
|
ST,STT,ES: Integer;
|
|
ST,STT,ES: Integer;
|
|
IDTag : DWord;
|
|
IDTag : DWord;
|
|
PIDTag : LPDWord;
|
|
PIDTag : LPDWord;
|
|
- PDeps,PN,PP : PAnsiChar;
|
|
|
|
- D : TServiceDescriptionA;
|
|
|
|
|
|
+ PDeps,PN,PP : PChar;
|
|
|
|
+ D : TServiceDescription;
|
|
|
|
|
|
begin
|
|
begin
|
|
SM:=TSMData(FSysData).FHandle;
|
|
SM:=TSMData(FSysData).FHandle;
|
|
@@ -211,12 +213,12 @@ begin
|
|
If (UN='') then
|
|
If (UN='') then
|
|
PN:=Nil
|
|
PN:=Nil
|
|
else
|
|
else
|
|
- PN:=PAnsiChar(UN);
|
|
|
|
|
|
+ PN:=PChar(UN);
|
|
UP:=Password;
|
|
UP:=Password;
|
|
if (UP='') then
|
|
if (UP='') then
|
|
PP:=Nil
|
|
PP:=Nil
|
|
else
|
|
else
|
|
- PP:=PAnsiChar(UP);
|
|
|
|
|
|
+ PP:=PChar(UP);
|
|
// ServiceType ST
|
|
// ServiceType ST
|
|
ST:=WinServiceTypes[ServiceType];
|
|
ST:=WinServiceTypes[ServiceType];
|
|
if (doInteractive in DD.Options) and (ServiceType=stWin32) then
|
|
if (doInteractive in DD.Options) and (ServiceType=stWin32) then
|
|
@@ -237,13 +239,13 @@ begin
|
|
PDeps:=GetDependencies(Dependencies);
|
|
PDeps:=GetDependencies(Dependencies);
|
|
end;
|
|
end;
|
|
Try
|
|
Try
|
|
- SV:=CreateService(SM, PAnsiChar(N), PAnsiChar(DN), SERVICE_ALL_ACCESS, ST, STT, ES,
|
|
|
|
- PAnsiChar(E), PAnsiChar(LG), PIDTag, PDeps, PN, PP);
|
|
|
|
|
|
+ SV:=CreateService(SM, PChar(N), PChar(DN), SERVICE_ALL_ACCESS, ST, STT, ES,
|
|
|
|
+ PChar(E), PChar(LG), PIDTag, PDeps, PN, PP);
|
|
If (SV=0) then
|
|
If (SV=0) then
|
|
RaiseLastOSError;
|
|
RaiseLastOSError;
|
|
Try
|
|
Try
|
|
SD:=DD.Description;
|
|
SD:=DD.Description;
|
|
- D.lpDescription:=PAnsiChar(SD);
|
|
|
|
|
|
+ D.lpDescription:=PChar(SD);
|
|
ChangeServiceConfig2(SV,SERVICE_CONFIG_DESCRIPTION,@D);
|
|
ChangeServiceConfig2(SV,SERVICE_CONFIG_DESCRIPTION,@D);
|
|
If (PIDTag<>Nil) then
|
|
If (PIDTag<>Nil) then
|
|
DD.WinBindings.IDTag:=IDTag;
|
|
DD.WinBindings.IDTag:=IDTag;
|
|
@@ -264,7 +266,7 @@ var
|
|
begin
|
|
begin
|
|
SM:=TSMData(FSysData).FHandle;
|
|
SM:=TSMData(FSysData).FHandle;
|
|
DN:=Daemon.Definition.Name;
|
|
DN:=Daemon.Definition.Name;
|
|
- SV:=OpenService(SM,PAnsiChar(DN),SERVICE_ALL_ACCESS);
|
|
|
|
|
|
+ SV:=OpenServiceA(SM,PAnsiChar(DN),SERVICE_ALL_ACCESS);
|
|
if (SV=0) then
|
|
if (SV=0) then
|
|
RaiseLastOSError;
|
|
RaiseLastOSError;
|
|
try
|
|
try
|
|
@@ -384,6 +386,7 @@ Var
|
|
P : PServiceTableEntry;
|
|
P : PServiceTableEntry;
|
|
I,C : Integer;
|
|
I,C : Integer;
|
|
RV : Integer;
|
|
RV : Integer;
|
|
|
|
+ SN : AnsiString;
|
|
|
|
|
|
begin
|
|
begin
|
|
GetMem(P,SizeOf(TServiceTableEntry)*(FMapper.DaemonDefs.Count+1));
|
|
GetMem(P,SizeOf(TServiceTableEntry)*(FMapper.DaemonDefs.Count+1));
|
|
@@ -392,7 +395,7 @@ begin
|
|
For I:=0 to C-1 do
|
|
For I:=0 to C-1 do
|
|
If Assigned(FMapper.DaemonDefs[i].Instance) then
|
|
If Assigned(FMapper.DaemonDefs[i].Instance) then
|
|
begin
|
|
begin
|
|
- P[i].lpServiceName:=PAnsiChar(FMapper.DaemonDefs[i].Name);
|
|
|
|
|
|
+ P[i].lpServiceName:=PChar(FMapper.DaemonDefs[i].Name);
|
|
P[i].lpServiceProc:=@ServiceMainEntry;
|
|
P[i].lpServiceProc:=@ServiceMainEntry;
|
|
end;
|
|
end;
|
|
// Set last entry to Nil.
|
|
// Set last entry to Nil.
|
|
@@ -506,7 +509,7 @@ begin
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
-procedure TDaemonController.Main(Argc: DWord; Args: PPAnsiChar);
|
|
|
|
|
|
+procedure TDaemonController.Main(Argc: DWord; Args: PPChar);
|
|
|
|
|
|
Var
|
|
Var
|
|
T : TThread;
|
|
T : TThread;
|