我查看了以往的帖子,发现都是用的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一样的效果谢谢!

解决方案 »

  1.   

    50分没人理,增加到100分求这几个API
      

  2.   

    出自 MSDN 
    装新的 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
      

  3.   

    http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257748
      

  4.   

    http://www.vckbase.com/bbs/prime/viewprime.asp?id=656
    这个大概是你需要的。