Skip to content

Commit 991db2d

Browse files
committed
Some code
1 parent 9364e83 commit 991db2d

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

Source/Unit1.pas

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,39 @@ procedure AddRuleToFirewall(const Caption, Executable: string; NET_FW_IP_PROTOCO
140140
RulesObject.Add(NewRule);
141141
end;
142142

143+
// Ïðîñòî ïðèìåð, âåðîÿòíî ñìûñëà íåò, ïîòîìó ÷òî äèàëîãè äîáàâëåíèÿ áóäóò íå ïðîùå, ÷åì â áðàíäìàóýåð
144+
// Just an example, probably no point, because the add dialogs will be no simpler than in the firewall
145+
// AddBlockPortRule('"TestPort"', 5791, NET_FW_IP_PROTOCOL_UDP, NET_FW_RULE_DIR_IN);
146+
{procedure AddBlockPortRule(const Caption: string; const Port: integer; NET_FW_IP_PROTOCOL, NET_FW_RULE_DIR: integer);
147+
const
148+
NET_FW_PROFILE2_DOMAIN = 1;
149+
NET_FW_PROFILE2_PRIVATE = 2;
150+
NET_FW_PROFILE2_PUBLIC = 4;
151+
152+
NET_FW_IP_PROTOCOL_TCP = 6;
153+
154+
NET_FW_ACTION_BLOCK = 0;
155+
var
156+
fwPolicy2: OleVariant;
157+
RulesObject: OleVariant;
158+
NewRule: OleVariant;
159+
Profile: integer;
160+
begin
161+
Profile:=NET_FW_PROFILE2_DOMAIN or NET_FW_PROFILE2_PRIVATE or NET_FW_PROFILE2_PUBLIC;
162+
fwPolicy2:=CreateOleObject('HNetCfg.FwPolicy2');
163+
RulesObject:=fwPolicy2.Rules;
164+
NewRule:=CreateOleObject('HNetCfg.FWRule');
165+
NewRule.Name:=Caption;
166+
NewRule.Description:=Caption; // + Port?
167+
NewRule.Protocol:=NET_FW_IP_PROTOCOL;
168+
NewRule.LocalPorts:=Port;
169+
NewRule.Direction:=NET_FW_RULE_DIR;
170+
NewRule.Enabled:=true;
171+
NewRule.Profiles:=Profile;
172+
NewRule.Action:=NET_FW_ACTION_BLOCK;
173+
RulesObject.Add(NewRule);
174+
end;}
175+
143176
procedure AddRulesForApp(const FilePath: string);
144177
var
145178
RuleCaption: string;

0 commit comments

Comments
 (0)