Verifying If Windows Firewall is Enabled in Delphi


April 2010.

function IsWindowsFireWallEnabled : boolean;
var
HNetCfg: OleVariant;
ShellApplication: OleVariant;
begin
ShellApplication := CreateOleObject('Shell.Application');
if not ShellApplication.IsServiceRunning('SharedAccess') then
begin
ShellApplication.ServiceStart('SharedAccess', true);
Sleep(2000);
end;

HNetCfg := CreateOLEObject('hnetcfg.fwmgr');
Result := HNetCfg.LocalPolicy.CurrentProfile.FirewallEnabled;
end;

Source:
* http://msdn.microsoft.com/en-us/library/aa366442%28VS.85%29.aspx