Registriert seit: 14. Apr 2003
Ort: Stuttgart
1.701 Beiträge
Delphi 7 Professional
|
Re: Windows Firewall - Eintrag erstellen / löschen / ändern
3. Mär 2009, 20:57
So isses besser, imho.
Delphi-Quellcode:
function IsWindowsFirewallServiceActive: Boolean;
var
SCM, hService: LongWord;
sStatus: TServiceStatus;
dwStat: Cardinal;
begin
SCM := OpenSCManager(nil, nil, SC_MANAGER_ENUMERATE_SERVICE);
if SCM <> 0 then
begin
hService := OpenService(SCM, PChar('SharedAccess'), SERVICE_QUERY_STATUS);
if hService = 0 then //Vista,Win7
hService := OpenService(SCM, PChar('MpsSvc'), SERVICE_QUERY_STATUS);
try
if (hService <> 0) then
begin
if (QueryServiceStatus(hService, sStatus)) then
begin
result := sStatus.dwCurrentState = SERVICE_RUNNING;
exit;
end;
end;
finally
CloseServiceHandle(SCM);
CloseServiceHandle(hService);
end;
end;
raise EAccessViolation.Create('Could not determine Firewall Service status');
end;
|
|
Zitat
|