Welcome to Vista Banter. You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to ask questions and reply to others posts, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact support. |
|
Security and Windows Vista A forum for discussion on security issues with Windows Vista. (microsoft.public.windows.vista.security) |
|
LinkBack | Thread Tools | Display Modes |
|
|||
Unable to set INetFWRule Interfaces property
Hi,
Apologies if this is not the correct place to post this message. I want to set firewall rule programmatically on just one Network Interface card identified by its Guid. I have the valid guid and i want to assign it to Interfaces property, I don't get compilation error but during run time i get "Value does not fall within the expected range." Here's a piece of my code snippet. INetFwRule NewFwRule = null; Type typeFWRule = Type.GetTypeFromProgID("HNetCfg.FWRule"); NewFwRule = (INetFwRule)Activator.CreateInstance(typeFWRule); Guid = {valid Guid of my wireless card} if (NewFwRule != null) { NewFwRule.Name = ruleName; NewFwRule.Description = ruleDesc; NewFwRule.ApplicationName = applnName; //NewFwRule.serviceName ="AthHostService"; NewFwRule.Protocol = protocol; NewFwRule.LocalPorts = localPorts; NewFwRule.Grouping = ruleGrouping; NewFwRule.Profiles = CurrentProfilesBitMask; NewFwRule.Action = NetFwTypeLib.NET_FW_ACTION_.NET_FW_ACTION_ALLOW; NewFwRule.Enabled = true; NewFwRule.InterfaceTypes = "Wireless"; NewFwRule.Interfaces = Guid;//----Exception comes here //Add the Firewall Rule if (fwPolicy2 != null) { fwPolicy2.Rules.Add(NewFwRule); } } Can anyone pls point out what is the mistake i am doing. Any help will be greatly appreciated. Thanks -- Anant |