我在XP下运行这个函数。成功!
但是用GetIpAddrTable获得IP信息后,有两个IP。
在“本地链接”状态的“支持”页中,IP已改变。
但在设置TCPIP属性中的IP地址还没有变。
另外,重启动以后,IP又恢复。
问题:我怎样才能真正的改IP地址呢?就像在设置TCPIP属性那样!

解决方案 »

  1.   

    重启动以后,IP为TCPIP属性中的IP地址,所以,需改变这个IP.
      

  2.   

    有CreateIPAddress这个函数吗?msdn查不到啊:0奇怪了
      

  3.   

    SORRY,这个函数是我做的!;)
    主要用了AddIPAddress & DeleteIPAddress
      

  4.   

    AddIPAddress & DeleteIPAddress
    也是你做的吗?好像这两个函数也查不到啊:D
      

  5.   

    回复人:tianlinyi(笨蛋) () 信誉:100  2002-4-30 11:33:53  删除  
     
      出自 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_MACHINE  
     
    2.  Find  the  subKey  =  SOFTWARE\Microsoft\Windows  NT\CurrentVersion\NetworkCards\  "netcard#    "  
     
     "netcard#    "  usually  is    "1  "  but  you  can  control  any  subkey  and  find  specific  netwrok  Adapters  
     
    Refer  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  address  
     
    6.  Set  data  for  the  value    "SubnetMask  "  to  change  subnet  mask    
     
    7.  Set  data  for  the  value    "DefaultGateway  "  to  change  default  gateway
      

  6.   

    to: MasterZ
    对啦,XP & 2000均可以再不重启动的基础上修改IP。
    他用的是什么方法呢?