About the author
Few days ago, I began work on a Windows Firewall component in Delphi, and my work is currently up on Github.
The name of the unit containing the Windows Firewall component is called System.Win.Firewall, and the component is called TWindowsFirewall. The example project has 2 functions. 1 function lists all the firewall rules, and the other creates a rule, blocking a list of addresses.
The function that lists all the firewall rules, look like so:
procedure ShowRule(const ARule: TWindowsFirewall.TWindowsFirewallRule); begin WriteLn('Name: ', ARule.Name); WriteLn('Action: ', ARule.Action.ToString); WriteLn('Description: ', ARule.Description); WriteLn('Direction: ', ARule.Direction.ToString); WriteLn('Enabled: ', ARule.Enabled); WriteLn('Profile: ', ARule.Profile.ToString); WriteLn('Interface Types: ', ARule.InterfaceTypes.ToString); WriteLn('-----------------------------------'); end; procedure EnumRules; var LFirewall: TWindowsFirewall; LRule: TWindowsFirewall.TWindowsFirewallRule; LRuleName, LInterface: string; begin LFirewall := TWindowsFirewall.Create; try for LRuleName in TArray<string>.Create('Doesn''t exist', 'Test rule using TWindowsFirewall') do if LFirewall.Rules.FindRule(LRuleName) then begin LRule := LFirewall.Rules[LRuleName]; ShowRule(LRule); LRule.Free; end; for LRule in LFirewall.Rules do ShowRule(LRule); finally LFirewall.Free; end; end; begin EnumRules; end.
Feel free to check out the repository, or if you're interested in extending/enhancing the component further, or collaborate with me.
How to free more space on your home drive by redirecting the location for SDKs in RAD Studio
Learn the command line used to compile System.pas in Delphi
A method to design records so that they're allocated on a specific byte boundary, such as 16 bytes, 512 bytes, 4096 bytes, etc.
Learn why the map is cool in Go!