Das funktioniert so
Delphi-Quellcode:
uses WinSvc;
const
SERVICE_CONFIG_DESCRIPTION = 1;
SERVICE_CONFIG_FAILURE_ACTIONS = 2;
type
TSERVICE_DESCRIPTION = packed record
lpDescription: PChar;
end;
function ChangeServiceConfig2A(hService: HWND; dwInfoLevel: DWord; lpInfo: Pointer): BOOL; stdcall; external 'advapi32.dll';
implementation
procedure SetServiceDescription(ServiceName, Description: String);
var
lDescription : TSERVICE_DESCRIPTION;
lManager,
lServiceHandle : Cardinal;
begin
lManager := OpenSCManager(nil, nil, SC_MANAGER_ALL_ACCESS);
if (lManager <> 0) then
begin
lServiceHandle := OpenService(lManager, PAnsiChar(ServiceName) , SERVICE_ALL_ACCESS);
if (lServiceHandle <> 0) then
begin
lDescription.lpDescription := PAnsiChar(Description);
ChangeServiceConfig2A(lServiceHandle, SERVICE_CONFIG_DESCRIPTION, @lDescription);
CloseServiceHandle(lServiceHandle);
end;
CloseServiceHandle(lManager);
end;
end;
Ich hoffe, dass ich nichts vergessen habe.
Die Funktion "SetServiceDescription" musst Du natürlich auch nocj irgendwo definieren.
Grüße Sven