Windows防火墙操作指南:端口、应用与规则管理
1. 移除Windows防火墙端口
在Windows系统中,有时需要移除防火墙开放的端口以增强安全性。以下是移除端口的具体代码:
private void btnDelete_Click(object sender, EventArgs e)
{
// Create the firewall type.
Type FWManagerType = Type.GetTypeFromProgID("HNetCfg.FwMgr");
// Use the firewall type to create a firewall manager object.
dynamic FWManager = Activator.CreateInstance(FWManagerType);
// Obtain the firewall profile information.
dynamic FWProfile = FWManager.LocalPolicy.CurrentProfile;
try
{
// Delete the port based on the port name.
FWProfile.GloballyOpenPorts.Remove(9999,NET_FW_IP_PROTOCOL_TCP);
// Display a success message.
MessageBox.Show("Port successfully deleted!");
}
超级会员免费看
订阅专栏 解锁全文

被折叠的 条评论
为什么被折叠?



