четвер, 29 листопада 2018 р.

Delphi warning "Unsafe type 'PChar'"

There is not only way to define it in the Delphi IDE settings by excluding raise of this type of warning.

var sa, sb: String; ca, cb: array[0..1023] of Char; … StrPCopy(ca, sa); StrPCopy(cb, sb);
  CopyFile(ca, cb, False); ...


Even better solution is to create class function:

type TCharArray = array[0..1023] of Char; ... class function TGeneralLibrary.StrToPChar(AText: String): TCharArray;
class function TGeneralLibrary.StrToPChar(AText: String): TCharArray; var cArray: TCharArray; begin StrPCopy(cArray, AText); Result := cArray; end; ...

неділя, 25 листопада 2018 р.

Kill service in command line

You don't have to restart your machine. Start cmd or PowerShell in elevated mode.
sc.exe queryex <SERVICE_NAME>
Then you'll get some info. A PID number will show.
taskkill /pid <SERVICE_PID> /f
Where /f is to force stop.
Now you can install or launch your service.