或者以另一种方式理解如何在VB.NET中绕过Windows的防火墙?
发布于 2011-10-22 05:47:28
我找到了通过托管代码访问Windows防火墙API的指南。这将允许你从你的程序中自动打开和关闭端口,这是你正在寻找的吗?
http://blogs.msdn.com/b/securitytools/archive/2009/08/21/automating-windows-firewall-settings-with-c.aspx
它特别给出了将程序添加到受信任程序列表的示例。
INetFwAuthorizedApplications applications;
INetFwAuthorizedApplication application;
application.Name = “Internet Explorer”;/*set the name of the application */
application.ProcessImageFileName = "C:\\Program Files\\Internet Explorer\\iexplore.exe" /* set this property to the location of the executable file of the application*/
application.Enabled = true; //enable it
/*now add this application to AuthorizedApplications collection */
Type NetFwMgrType = Type.GetTypeFromProgID("HNetCfg.FwMgr", false);
INetFwMgr mgr = (INetFwMgr)Activator.CreateInstance(NetFwMgrType);
applications = (INetFwAuthorizedApplications)mgr.LocalPolicy.CurrentProfile.AuthorizedApplications;
applications.Add(application);基于评论的编辑基于评论的看起来你真正想看的是代码签名。http://en.wikipedia.org/wiki/Code_signing
这通常意味着购买证书(类似于SSL)并将其应用于已编译的应用程序。这与.NET的签名不同,它是赋予程序集强名称的一部分,它是不同的东西。
https://stackoverflow.com/questions/7853057
复制相似问题