以编程方式启用Internet连接共享 [英] Enable Internet Connection Sharing programmatically

查看:101
本文介绍了以编程方式启用Internet连接共享的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以通过右键单击网络连接,打开共享"选项卡,单击允许其他网络用户通过此计算机的Internet连接进行连接"复选框,然后选择家庭网络连接"来手动完成此操作.

在研究这个问题时,我发现了多套COM接口:

1) Internet连接与INetSharingManager共享和Internet连接防火墙接口

它的文档说:

Internet连接防火墙可能已更改或不可用 后续版本.而是使用Windows防火墙API.

此外, INetSharingConfiguration .EnableSharing 方法看起来不像上面描述的过程,因为它的参数不包括家庭网络连接".

2) Windows防火墙用于带有SP2接口的Windows XP

其文档进一步引用了我们:

对于Windows Vista和更高版本,将Windows防火墙与高级功能一起使用 建议使用安全性API.

3) Windows防火墙使用高级安全性API

只有以下接口:INetFwPolicy2, INetFwProduct, INetFwProducts, INetFwRule, INetFwRule2, INetFwRule3, INetFwRules, INetFwServiceRestriction.看起来不太有前途.

现在我迷路了.在Windows 7上应该使用哪个API?

解决方案

utapyngo

您的最终选择是什么?

http://social.msdn.microsoft.com/Forums/en-tw/windowssdk/thread/19f7581d-29c7-4109-85d4-6a79ee4d1577

我能够找到解决方案.您必须在要连接的适配器上启用公共接口,并在专用接口上启用要用于网络的适配器的共享."

I can do it manually by right-clicking on a network connection, opening the Sharing tab, clicking on the "Allow other network users to connect through this computer's Internet connection" check box, and selecting a "Home networking connection".

While poking around this problem I have found multiple sets of COM interfaces:

1) Internet Connection Sharing and Internet Connection Firewall Interfaces with INetSharingManager

Its documentation says:

Internet Connection Firewall may be altered or unavailable in subsequent versions. Instead, use the Windows Firewall API.

Moreover, the INetSharingConfiguration.EnableSharing method does not look like it corresponds the procedure described above because its arguments don't include the "Home networking connection".

2) Windows Firewall for Windows XP with SP2 Interfaces

Its documentation references us further:

For Windows Vista and later, use of the Windows Firewall with Advanced Security API is recommended.

3) Windows Firewall with Advanced Security API

There are only the following interfaces: INetFwPolicy2, INetFwProduct, INetFwProducts, INetFwRule, INetFwRule2, INetFwRule3, INetFwRules, INetFwServiceRestriction. Does not look very promising.

Now I'm lost. Which API should I use on Windows 7?

解决方案

utapyngo

Which is your final choice?

http://social.msdn.microsoft.com/Forums/en-tw/windowssdk/thread/19f7581d-29c7-4109-85d4-6a79ee4d1577

"I was able to find the solution. You have to enable the public interface on the adapter you are connecting to and enable sharing on the private interface for the adapter you want to be able to use for the network."

这篇关于以编程方式启用Internet连接共享的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆