在注册表里有(以下在NT4下,其他也差不多在[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services
这。NdisWan7是设备名,如adsl,isdn等。
[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\NdisWan7\Parameters\Tcpip]
"EnableDHCP"=dword:00000000
"UseZeroBroadcast"=dword:00000000
"LLInterface"="\\Device\\RASARP"
"IPAddress"=hex(7):30,2e,30,2e,30,2e,30,00,00
"SubnetMask"=hex(7):30,2e,30,2e,30,2e,30,00,00
"DefaultGateway"=hex(7):00
"MTU"=dword:00000578
"IPInterfaceContext"=dword:00000006
"IPInterfaceContextMax"=dword:00000006
"DhcpIPAddress"="218.19.66.142"   //此为Internet本机IP
"DhcpSubnetMask"="255.255.255.0"
你用API函数,读取DhcpIPAddress的值就可以了。

解决方案 »

  1.   

    在注册表里有(以下在NT4下,其他也差不多在[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services
    这。NdisWan7是设备名,如adsl,isdn等。
    [HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\NdisWan7\Parameters\Tcpip]
    "EnableDHCP"=dword:00000000
    "UseZeroBroadcast"=dword:00000000
    "LLInterface"="\\Device\\RASARP"
    "IPAddress"=hex(7):30,2e,30,2e,30,2e,30,00,00
    "SubnetMask"=hex(7):30,2e,30,2e,30,2e,30,00,00
    "DefaultGateway"=hex(7):00
    "MTU"=dword:00000578
    "IPInterfaceContext"=dword:00000006
    "IPInterfaceContextMax"=dword:00000006
    "DhcpIPAddress"="218.19.66.142"   //此为Internet本机IP
    "DhcpSubnetMask"="255.255.255.0"
    你用API函数,读取DhcpIPAddress的值就可以了。
      

  2.   

    我这里也有一段代码供你参考:public function GetIPAddress() as string
    dim sHostName as string*256
    dim lpHost as long
    dim Host as HOSTENT
    dim dwIPAddr as long
    dim tmpIPAddr() as Byte
    dim i as integer
    dim sIPAddr as stringif not sockersInitialize() then
        GetIPAddress=""
        exit function
    end ifif gethostname(sHostName,256)=socket_error then
        getipaddress=""
        msgbox "Windows Sockets error"
        SocketsCleanup
        exit function
    end ifsHostName=trim$(sHostName)
    lpHost=gethostbyname(sHostName)
    if lpHost=0 then
         getipaddress=""
         msgbox "windows sockets are not responding"
         socketsCleanup
         exit function
    end ifcopymemory host,lphost,len(host)
    copymemory dwipaddr,host.haddlist,4
    redim tmpipaddr(1 to host.hlen)
    copymemory tmpipaddr(1),dwipaddr,host.hlen
    for i=1 to host.hlen
        sipaddr=sipaddr & tmpipaddr(i) & "."
    next
    getipaddress=mid$(sipaddr,1,len(sipaddr)-1)
    socketsCleanup
    end function
      

  3.   

    在WINDOWS98下是哪一个键呀?我没找到?
    还有其它方法吗?
      

  4.   

    TO: lily0000000
    请再将以下几个函数的内容贴出来,谢谢。
    sockersInitialize() 
    gethostname(sHostName,256)
    gethostbyname(sHostName)
    socketsCleanup()
      

  5.   

    to acev(acev) 
    为什么我查找整个注册表里也没有DhcpIPAddress这个键呢.我用的2000,请问是什么原因.