type
TServicesDesciption =
record
lpDescription: PChar;
end;
PServicesDesciption = ^PServicesDesciption;
function QueryServiceConfig2(
hService: SC_HANDLE;
dwInfoLevel: DWORD;
lpBuffer: PBYTE;
cbBufSize: DWORD;
pcbBytesNeeded: LPDWORD): LongBool;
function QueryServiceConfig2;
external Windows.advapi32
name '
QueryServiceConfig2A';
//Ansi
//function QueryServiceConfig2; external Windows.advapi32 name 'QueryServiceConfig2W'; //Uni
function GetServiceDescription(AServicename: PChar):
String;
Const
SERVICE_CONFIG_DESCRIPTION = 1;
var
MgrHWND, SvcHWND: SC_Handle;
ServiceDesciption: PServicesDesciption;
cbBufSize: DWORD;
pcbBytesNeeded: LPDWORD;
begin
MgrHWND := OpenSCManager(
nil,
nil, SC_MANAGER_CONNECT);
if MgrHWND > 0
then begin
SvcHWND := WinSvc.OpenService(MgrHWND, AServicename, SERVICE_QUERY_CONFIG);
if SvcHWND > 0
then begin
cbBufSize := 512;
pcbBytesNeeded :=
nil;
GetMem(ServiceDesciption, cbBufSize);
if QueryServiceConfig2(SvcHWND, SERVICE_CONFIG_DESCRIPTION, @ServiceDesciption, cbBufSize, @pcbBytesNeeded)
then
Result := ^PServiceDesciption.lpDescription
// was stimmt hier noch nicht??
else
Result := SysErrorMessage(GetLastError);
end;
CloseServiceHandle(SvcHWND);
end;
CloseServiceHandle(MgrHWND);
end;