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.
Continued discussion of undocumented Delphi 8 Property Access Specifiers, and other ways of adding and removing delegates / events handlers, including clearing the list of all the delegates / event handlers.
This article discusses the new Delphi 8 property access specifiers.
A method pointer is now the same as a global procedure, ie, procedure of object = procedure.