我查看了以往的帖子,发现都是用的AddIPAddress这个函数,可是MSDN中的注释说
The IP address created by AddIPAddress is not persistent. The address exists only as long as the adapter object exists. Restarting the computer destroys the address, as does manually resetting the network interface card (NIC). Also, certain PnP events may destroy the address.而且,对应的DeleteIPAddress需要AddIPAddress的返回参数才能删除一个IP,不能删除当前已经绑定的IP。如果一个IP不是用AddIPAddress添加的,就没法用DeleteIPAddress删除了。我希望能够永久的添加/删除IP地址,是否还需要一个通知IP更改的函数呢?
就跟在控制面板-〉网络连接的属性中添加/删除IP一样的效果谢谢!
The IP address created by AddIPAddress is not persistent. The address exists only as long as the adapter object exists. Restarting the computer destroys the address, as does manually resetting the network interface card (NIC). Also, certain PnP events may destroy the address.而且,对应的DeleteIPAddress需要AddIPAddress的返回参数才能删除一个IP,不能删除当前已经绑定的IP。如果一个IP不是用AddIPAddress添加的,就没法用DeleteIPAddress删除了。我希望能够永久的添加/删除IP地址,是否还需要一个通知IP更改的函数呢?
就跟在控制面板-〉网络连接的属性中添加/删除IP一样的效果谢谢!
解决方案 »
- 关于OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)的问题
- install factory制作的安装文件太大
- 求助:FTP流量检测如何做?
- ----==== 请问我想系统地学习D3D技术,那里有学 ====----
- 怎么样才能看到winmain函数(mfc隐藏了)
- 一个很简单的问题
- 散分了,正好介绍一下我开发的系统工具。XP下是毛玻璃效果。
- 怎么知道u盘插入了哪个usb口?
- 怎样让一个程序开机第一个运行?
- 新手请教COM编程中的数据类型
- 请教如何让对话框控件如LISTCTRL,RICHEDIT的边框可以由用户动态伸缩
- 菜鸟问题:如何新建一个Dialog
装新的 Platform SDK 就有 iphlpapi.h和iphlpapi.lib 了。请注意 Res 节中的如下内容
The IP address created by AddIPAddress is not persistent. The address exists only as long as the adapter object exists. Restarting the computer destroys the address, as does manually resetting the network interface card (NIC). Also, certain PnP events may destroy the address.就是说系统重启、适配器的禁用/启用都会使添加的IP销毁。要添加稳定长效的IP只能:1. Open registry on the HKEY_LOCAL_MACHINE2. Find the subKey = SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\"netcard# ""netcard# " usually is "1" but you can control any subkey and find specific netwrok AdaptersRefer to "MSDN Registry Entries for Network Adapter Cards"3. Get data for the value "ServiceName"4. Find the subKey = SYSTEM\CurrentControlSet\Services\"ServiceName"\Parameters\TcpIp" 5. Set data for the value "IpAddress" to change IP address6. Set data for the value "SubnetMask" to change subnet mask 7. Set data for the value "DefaultGateway" to change default gateway
这个大概是你需要的。