mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-13 11:39:24 +02:00
* PChar -> PAnsiChar
This commit is contained in:
parent
6de2577251
commit
550af49112
@ -133,7 +133,7 @@ Type
|
|||||||
Constructor Create(AOwner : TComponent); override;
|
Constructor Create(AOwner : TComponent); override;
|
||||||
Destructor Destroy; override;
|
Destructor Destroy; override;
|
||||||
Procedure StartService; virtual;
|
Procedure StartService; virtual;
|
||||||
Procedure Main(Argc : DWord; Args : PPChar); Virtual;
|
Procedure Main(Argc : DWord; Args : PPAnsiChar); Virtual;
|
||||||
Procedure Controller(ControlCode,EventType : DWord; EventData : Pointer); Virtual;
|
Procedure Controller(ControlCode,EventType : DWord; EventData : Pointer); Virtual;
|
||||||
Function ReportStatus : Boolean; virtual;
|
Function ReportStatus : Boolean; virtual;
|
||||||
Property Daemon : TCustomDaemon Read FDaemon;
|
Property Daemon : TCustomDaemon Read FDaemon;
|
||||||
@ -367,7 +367,7 @@ Type
|
|||||||
procedure SysUnInstallDaemon(Daemon: TCustomDaemon);
|
procedure SysUnInstallDaemon(Daemon: TCustomDaemon);
|
||||||
function UnInstallRun: Boolean;
|
function UnInstallRun: Boolean;
|
||||||
function RunDaemonsRun: Boolean;
|
function RunDaemonsRun: Boolean;
|
||||||
Procedure Main(Argc : DWord; Args : PPchar);
|
Procedure Main(Argc : DWord; Args : PPAnsiChar);
|
||||||
Function RunGUIloop(P : Pointer) : integer;
|
Function RunGUIloop(P : Pointer) : integer;
|
||||||
Protected
|
Protected
|
||||||
// OS (System) dependent calls
|
// OS (System) dependent calls
|
||||||
@ -772,7 +772,7 @@ begin
|
|||||||
// No Borland compatibility needed, as the install will take care of the -r
|
// No Borland compatibility needed, as the install will take care of the -r
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomDaemonApplication.Main(Argc: DWord; Args: PPchar);
|
procedure TCustomDaemonApplication.Main(Argc: DWord; Args: PPAnsiChar);
|
||||||
|
|
||||||
Var
|
Var
|
||||||
SN : String;
|
SN : String;
|
||||||
|
@ -206,7 +206,7 @@ var
|
|||||||
Stream: TResourceStream;
|
Stream: TResourceStream;
|
||||||
begin
|
begin
|
||||||
FreeResources;
|
FreeResources;
|
||||||
Stream := TResourceStream.CreateFromID(Instance, 1, {$ifdef FPC_OS_UNICODE}PWideChar{$else}PChar{$endif}(RT_VERSION));
|
Stream := TResourceStream.CreateFromID(Instance, 1, {$ifdef FPC_OS_UNICODE}PWideChar{$else}PAnsiChar{$endif}(RT_VERSION));
|
||||||
try
|
try
|
||||||
FVersionInfo:=TVersionResource.Create;
|
FVersionInfo:=TVersionResource.Create;
|
||||||
FVersionInfo.SetCustomRawDataStream(Stream);
|
FVersionInfo.SetCustomRawDataStream(Stream);
|
||||||
|
@ -157,7 +157,7 @@ begin
|
|||||||
Main(0,Nil);
|
Main(0,Nil);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TDaemonController.Main(Argc: DWord; Args: PPChar);
|
procedure TDaemonController.Main(Argc: DWord; Args: PPAnsiChar);
|
||||||
|
|
||||||
Var
|
Var
|
||||||
T : TThread;
|
T : TThread;
|
||||||
|
@ -203,7 +203,7 @@ ResourceString
|
|||||||
{$ifdef ver130}
|
{$ifdef ver130}
|
||||||
|
|
||||||
Type
|
Type
|
||||||
PCharArray = Array[Word] of PChar;
|
PCharArray = Array[Word] of PAnsiChar;
|
||||||
PPCharArray = ^PCharArray;
|
PPCharArray = ^PCharArray;
|
||||||
|
|
||||||
Procedure RaiseLastOSError;
|
Procedure RaiseLastOSError;
|
||||||
@ -227,14 +227,14 @@ end;
|
|||||||
procedure TServiceManager.Connect;
|
procedure TServiceManager.Connect;
|
||||||
|
|
||||||
Var
|
Var
|
||||||
P : PChar;
|
P : PAnsiChar;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
If (FHandle=0) then
|
If (FHandle=0) then
|
||||||
begin
|
begin
|
||||||
P:=Nil;
|
P:=Nil;
|
||||||
If (MachineName<>'') then
|
If (MachineName<>'') then
|
||||||
P:=PChar(MachineName);
|
P:=PAnsiChar(MachineName);
|
||||||
FHandle:=OpenSCManager(P,Nil,FAccess);
|
FHandle:=OpenSCManager(P,Nil,FAccess);
|
||||||
If (FHandle=0) then
|
If (FHandle=0) then
|
||||||
RaiseLastOSError;
|
RaiseLastOSError;
|
||||||
@ -308,7 +308,7 @@ begin
|
|||||||
FDisplayName:=StrPas(lpDisplayName);
|
FDisplayName:=StrPas(lpDisplayName);
|
||||||
SetStatusFields(ServiceStatus);
|
SetStatusFields(ServiceStatus);
|
||||||
end;
|
end;
|
||||||
PChar(P):=Pchar(P)+SizeOf(TEnumServiceStatus);
|
PAnsiChar(P):=PAnsiChar(P)+SizeOf(TEnumServiceStatus);
|
||||||
end;
|
end;
|
||||||
Finally
|
Finally
|
||||||
FreeMem(Info);
|
FreeMem(Info);
|
||||||
@ -424,7 +424,7 @@ begin
|
|||||||
FBeforeDisconnect(Self);
|
FBeforeDisconnect(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function AllocDependencyList (Const S : String) : PChar;
|
Function AllocDependencyList (Const S : String) : PAnsiChar;
|
||||||
|
|
||||||
Var
|
Var
|
||||||
I,L : Integer;
|
I,L : Integer;
|
||||||
@ -448,7 +448,7 @@ end;
|
|||||||
Function TServiceManager.RegisterService(var Desc: TServiceDescriptor) : Thandle;
|
Function TServiceManager.RegisterService(var Desc: TServiceDescriptor) : Thandle;
|
||||||
|
|
||||||
Var
|
Var
|
||||||
PDep,PLO,PUser,PPWd : PChar; // We need Nil for some things.
|
PDep,PLO,PUser,PPWd : PAnsiChar; // We need Nil for some things.
|
||||||
N,D : String;
|
N,D : String;
|
||||||
ReturnTag : DWord;
|
ReturnTag : DWord;
|
||||||
|
|
||||||
@ -460,19 +460,19 @@ begin
|
|||||||
If (LoadOrderGroup='') then
|
If (LoadOrderGroup='') then
|
||||||
PLO:=Nil
|
PLO:=Nil
|
||||||
else
|
else
|
||||||
PLO:=PChar(LoadOrderGroup);
|
PLO:=PAnsiChar(LoadOrderGroup);
|
||||||
PPwd:=Nil;
|
PPwd:=Nil;
|
||||||
PUser:=Nil;
|
PUser:=Nil;
|
||||||
If (UserName<>'') then
|
If (UserName<>'') then
|
||||||
begin
|
begin
|
||||||
PUser:=PChar(UserName);
|
PUser:=PAnsiChar(UserName);
|
||||||
If (Password<>'') then
|
If (Password<>'') then
|
||||||
PPWd:=PChar(Password);
|
PPWd:=PAnsiChar(Password);
|
||||||
end;
|
end;
|
||||||
PDep:=AllocDependencyList(Dependencies);
|
PDep:=AllocDependencyList(Dependencies);
|
||||||
Try
|
Try
|
||||||
Result:=CreateService(Self.Handle,PChar(N),PChar(D),DesiredAccess,ServiceType,
|
Result:=CreateService(Self.Handle,PAnsiChar(N),PAnsiChar(D),DesiredAccess,ServiceType,
|
||||||
StartType,ErrorControl,PChar(CommandLine),PLO,Nil,
|
StartType,ErrorControl,PAnsiChar(CommandLine),PLO,Nil,
|
||||||
PDep,PUser,PPwd);
|
PDep,PUser,PPwd);
|
||||||
If (Result=0) then
|
If (Result=0) then
|
||||||
RaiseLastOSError;
|
RaiseLastOSError;
|
||||||
@ -489,7 +489,7 @@ Var
|
|||||||
H : THandle;
|
H : THandle;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
H:=OpenService(Handle,PChar(ServiceName),SERVICE_ENUMERATE_DEPENDENTS);
|
H:=OpenService(Handle,PAnsiChar(ServiceName),SERVICE_ENUMERATE_DEPENDENTS);
|
||||||
try
|
try
|
||||||
ListDependentServices(H,ServiceState,List);
|
ListDependentServices(H,ServiceState,List);
|
||||||
Finally
|
Finally
|
||||||
@ -520,7 +520,7 @@ begin
|
|||||||
For I:=0 to Count-1 do
|
For I:=0 to Count-1 do
|
||||||
begin
|
begin
|
||||||
List.Add(StrPas(E^.lpServiceName));
|
List.Add(StrPas(E^.lpServiceName));
|
||||||
Pchar(E):=PChar(E)+SizeOf(TEnumServiceStatus);
|
PAnsiChar(E):=PAnsiChar(E)+SizeOf(TEnumServiceStatus);
|
||||||
end;
|
end;
|
||||||
Finally
|
Finally
|
||||||
FreeMem(P);
|
FreeMem(P);
|
||||||
@ -567,7 +567,7 @@ begin
|
|||||||
A:=SERVICE_STOP or SERVICE_QUERY_STATUS;
|
A:=SERVICE_STOP or SERVICE_QUERY_STATUS;
|
||||||
If StopDependent then
|
If StopDependent then
|
||||||
A:=A or SERVICE_ENUMERATE_DEPENDENTS;
|
A:=A or SERVICE_ENUMERATE_DEPENDENTS;
|
||||||
H:=OpenService(Handle,PChar(ServiceName),A);
|
H:=OpenService(Handle,PAnsiChar(ServiceName),A);
|
||||||
Try
|
Try
|
||||||
StopService(H,StopDependent);
|
StopService(H,StopDependent);
|
||||||
Finally
|
Finally
|
||||||
@ -579,7 +579,7 @@ end;
|
|||||||
Function TServiceManager.GetServiceHandle(const ServiceName : String; SAccess : DWord) : THandle;
|
Function TServiceManager.GetServiceHandle(const ServiceName : String; SAccess : DWord) : THandle;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result:=OpenService(Handle,PChar(ServiceName),SAccess);
|
Result:=OpenService(Handle,PAnsiChar(ServiceName),SAccess);
|
||||||
If (Result=0) then
|
If (Result=0) then
|
||||||
RaiseLastOSError;
|
RaiseLastOSError;
|
||||||
end;
|
end;
|
||||||
@ -649,7 +649,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function StringsToPCharList(List : TStrings) : PPChar;
|
Function StringsToPCharList(List : TStrings) : PPAnsiChar;
|
||||||
|
|
||||||
Var
|
Var
|
||||||
I : Integer;
|
I : Integer;
|
||||||
@ -657,25 +657,25 @@ Var
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
I:=(List.Count)+1;
|
I:=(List.Count)+1;
|
||||||
GetMem(Result,I*sizeOf(PChar));
|
GetMem(Result,I*sizeOf(PAnsiChar));
|
||||||
PPCharArray(Result)^[List.Count]:=Nil;
|
PPCharArray(Result)^[List.Count]:=Nil;
|
||||||
For I:=0 to List.Count-1 do
|
For I:=0 to List.Count-1 do
|
||||||
begin
|
begin
|
||||||
S:=List[i];
|
S:=List[i];
|
||||||
PPCharArray(Result)^[i]:=StrNew(PChar(S));
|
PPCharArray(Result)^[i]:=StrNew(PAnsiChar(S));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure FreePCharList(List : PPChar);
|
Procedure FreePCharList(List : PPAnsiChar);
|
||||||
|
|
||||||
Var
|
Var
|
||||||
I : integer;
|
I : integer;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
I:=0;
|
I:=0;
|
||||||
While PPChar(List)[i]<>Nil do
|
While PPAnsiChar(List)[i]<>Nil do
|
||||||
begin
|
begin
|
||||||
StrDispose(PPChar(List)[i]);
|
StrDispose(PPAnsiChar(List)[i]);
|
||||||
Inc(I);
|
Inc(I);
|
||||||
end;
|
end;
|
||||||
FreeMem(List);
|
FreeMem(List);
|
||||||
@ -685,7 +685,7 @@ Procedure TServiceManager.StartService(SHandle : THandle; Args : TStrings);
|
|||||||
|
|
||||||
Var
|
Var
|
||||||
Argc : DWord;
|
Argc : DWord;
|
||||||
PArgs : PPchar;
|
PArgs : PPAnsiChar;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
If (Args=Nil) or (Args.Count>0) then
|
If (Args=Nil) or (Args.Count>0) then
|
||||||
@ -699,7 +699,7 @@ begin
|
|||||||
Pargs:=StringsToPcharList(Args);
|
Pargs:=StringsToPcharList(Args);
|
||||||
end;
|
end;
|
||||||
Try
|
Try
|
||||||
If not jwawinsvc.StartService(SHandle,Argc,Pchar(PArgs)) then
|
If not jwawinsvc.StartService(SHandle,Argc,PAnsiChar(PArgs)) then
|
||||||
RaiseLastOSError;
|
RaiseLastOSError;
|
||||||
Finally
|
Finally
|
||||||
If (PArgs<>Nil) then
|
If (PArgs<>Nil) then
|
||||||
@ -817,17 +817,17 @@ end;
|
|||||||
|
|
||||||
procedure TServiceManager.ConfigService(SHandle : THandle ; Config : TServiceDescriptor);
|
procedure TServiceManager.ConfigService(SHandle : THandle ; Config : TServiceDescriptor);
|
||||||
|
|
||||||
Function SToPchar(Var S : String) : PChar;
|
Function SToPchar(Var S : String) : PAnsiChar;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
If (S='') then
|
If (S='') then
|
||||||
Result:=Nil
|
Result:=Nil
|
||||||
else
|
else
|
||||||
Result:=PChar(S);
|
Result:=PAnsiChar(S);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Var
|
Var
|
||||||
PDep,PLO,PUser,PPWd,PCmd,PDisp : PChar; // We need Nil for some things.
|
PDep,PLO,PUser,PPWd,PCmd,PDisp : PAnsiChar; // We need Nil for some things.
|
||||||
D : String;
|
D : String;
|
||||||
ReturnTag : DWord;
|
ReturnTag : DWord;
|
||||||
|
|
||||||
|
@ -40,11 +40,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 : Pchar); stdcall;
|
Procedure ServiceMainEntry(Argc : DWord; Args : PAnsiChar); stdcall;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
If Assigned(Application) then
|
If Assigned(Application) then
|
||||||
Application.Main(Argc,PPChar(Args));
|
Application.Main(Argc,PPAnsiChar(Args));
|
||||||
{$ifdef svcdebug}Debuglog('Main end');{$endif}
|
{$ifdef svcdebug}Debuglog('Main end');{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -150,11 +150,11 @@ const
|
|||||||
|
|
||||||
// Careful, result of this function must be freed !!
|
// Careful, result of this function must be freed !!
|
||||||
|
|
||||||
Function GetDependencies(D : TDependencies) : PChar;
|
Function GetDependencies(D : TDependencies) : PAnsiChar;
|
||||||
|
|
||||||
var
|
var
|
||||||
I,L : Integer;
|
I,L : Integer;
|
||||||
P : PChar;
|
P : PAnsiChar;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result:=Nil;
|
Result:=Nil;
|
||||||
@ -170,10 +170,10 @@ begin
|
|||||||
begin
|
begin
|
||||||
if D[i].IsGroup then
|
if D[i].IsGroup then
|
||||||
begin
|
begin
|
||||||
P^:=Char(SC_GROUP_IDENTIFIER);
|
P^:=AnsiChar(SC_GROUP_IDENTIFIER);
|
||||||
Inc(P);
|
Inc(P);
|
||||||
end;
|
end;
|
||||||
P:=StrECopy(P,PChar(D[i].Name));
|
P:=StrECopy(P,PAnsiChar(D[i].Name));
|
||||||
Inc(P);
|
Inc(P);
|
||||||
end;
|
end;
|
||||||
P^:=#0;
|
P^:=#0;
|
||||||
@ -184,12 +184,12 @@ Procedure TCustomDaemonApplication.SysInstallDaemon(Daemon : TCustomDaemon);
|
|||||||
|
|
||||||
Var
|
Var
|
||||||
SM,SV: SC_HANDLE;
|
SM,SV: SC_HANDLE;
|
||||||
SD,N,DN,E,LG,UN,UP : String;
|
SD,N,DN,E,LG,UN,UP : AnsiString;
|
||||||
DD : TDaemonDef;
|
DD : TDaemonDef;
|
||||||
ST,STT,ES: Integer;
|
ST,STT,ES: Integer;
|
||||||
IDTag : DWord;
|
IDTag : DWord;
|
||||||
PIDTag : LPDWord;
|
PIDTag : LPDWord;
|
||||||
PDeps,PN,PP : PChar;
|
PDeps,PN,PP : PAnsiChar;
|
||||||
D : TServiceDescriptionA;
|
D : TServiceDescriptionA;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@ -211,12 +211,12 @@ begin
|
|||||||
If (UN='') then
|
If (UN='') then
|
||||||
PN:=Nil
|
PN:=Nil
|
||||||
else
|
else
|
||||||
PN:=PChar(UN);
|
PN:=PAnsiChar(UN);
|
||||||
UP:=Password;
|
UP:=Password;
|
||||||
if (UP='') then
|
if (UP='') then
|
||||||
PP:=Nil
|
PP:=Nil
|
||||||
else
|
else
|
||||||
PP:=PChar(UP);
|
PP:=PAnsiChar(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 +237,13 @@ begin
|
|||||||
PDeps:=GetDependencies(Dependencies);
|
PDeps:=GetDependencies(Dependencies);
|
||||||
end;
|
end;
|
||||||
Try
|
Try
|
||||||
SV:=CreateService(SM, PChar(N), PChar(DN), SERVICE_ALL_ACCESS, ST, STT, ES,
|
SV:=CreateService(SM, PAnsiChar(N), PAnsiChar(DN), SERVICE_ALL_ACCESS, ST, STT, ES,
|
||||||
PChar(E), PChar(LG), PIDTag, PDeps, PN, PP);
|
PAnsiChar(E), PAnsiChar(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:=Pchar(SD);
|
D.lpDescription:=PAnsiChar(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;
|
||||||
@ -260,11 +260,11 @@ procedure TCustomDaemonApplication.SysUnInstallDaemon(Daemon: TCustomDaemon);
|
|||||||
|
|
||||||
var
|
var
|
||||||
SM,SV : SC_HANDLE;
|
SM,SV : SC_HANDLE;
|
||||||
DN : String;
|
DN : AnsiString;
|
||||||
begin
|
begin
|
||||||
SM:=TSMData(FSysData).FHandle;
|
SM:=TSMData(FSysData).FHandle;
|
||||||
DN:=Daemon.Definition.Name;
|
DN:=Daemon.Definition.Name;
|
||||||
SV:=OpenService(SM,PChar(DN),SERVICE_ALL_ACCESS);
|
SV:=OpenService(SM,PAnsiChar(DN),SERVICE_ALL_ACCESS);
|
||||||
if (SV=0) then
|
if (SV=0) then
|
||||||
RaiseLastOSError;
|
RaiseLastOSError;
|
||||||
try
|
try
|
||||||
@ -346,7 +346,7 @@ begin
|
|||||||
if Windows.RegisterClassA(AWClass) = 0 then
|
if Windows.RegisterClassA(AWClass) = 0 then
|
||||||
DaemonError(SErrWindowClass);
|
DaemonError(SErrWindowClass);
|
||||||
end;
|
end;
|
||||||
GUIHandle := CreateWindowA(AWClass.lpszClassName, Pchar(Title),
|
GUIHandle := CreateWindowA(AWClass.lpszClassName, PAnsiChar(Title),
|
||||||
HandleOpts, 1,1, 0, 0, 0, 0, HInstance, nil);
|
HandleOpts, 1,1, 0, 0, 0, 0, HInstance, nil);
|
||||||
end;
|
end;
|
||||||
T:=TDaemonStartThread.Create(P,GUIHandle);
|
T:=TDaemonStartThread.Create(P,GUIHandle);
|
||||||
@ -392,7 +392,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:=Pchar(FMapper.DaemonDefs[i].Name);
|
P[i].lpServiceName:=PAnsiChar(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 +506,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TDaemonController.Main(Argc: DWord; Args: PPChar);
|
procedure TDaemonController.Main(Argc: DWord; Args: PPAnsiChar);
|
||||||
|
|
||||||
Var
|
Var
|
||||||
T : TThread;
|
T : TThread;
|
||||||
|
Loading…
Reference in New Issue
Block a user