Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: IP Address


Message #1 by "Nagendra Kumar K" <knagendrak@h...> on Tue, 19 Nov 2002 05:47:21 +0000
' Script to retrieve the current IP Address on the first network card.
'
' (c) 2002 A.J. Elsinga
'      anne.jan@n...
'
'      version 1.0


' ************************************************************
' ***           Start of functions and procedures          ***
' ************************************************************

Function GetIPAddress
' This function retrieves the IP Address from the registry
' It gets it from the CurrentControlSet, so even when using DHCP
' it returns the correct IP Address

' Declare variables

   Dim key
   Dim cTempIPAddress
   Dim cIPAddress
   dim cIPAddressKey


   Set oSh = CreateObject("WScript.Shell")


cInterfacesKey="HKLM\SYSTEM\CurrentControlSet\Services\TCPIP\Parameters\Inte
rfaces\"
   cNICSearch="HKLM\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\NetworkCards\1\ServiceName"


' First check which network card to use
   cNicServiceName=oSh.RegRead(cNICSearch)

' Now read the IP Address from that card
   cIPAddressKey=cInterfaceskey + cNicServiceName+"\IPAddress"
   cTempIPAddress=oSh.RegRead (cIPAddresskey)

' Split the items in the var tempIPAddress to the octets in array IPAddress
   cIPAddress=split (cTempIPAddress(0),".",4)

' the IP addresss is now readable from ipaddress
' for example, to read the first octet, use: FirstOctet=IPAddress(0)

   GetIPAddress=cIPAddress
End Function

Function GetIPOctet (nOctet)
' This function retrieves a given octet out of the IP Address
    Dim IPAddress

    IPAddress=GetIPAddress
    GetIPOctet=IPAddress(nOctet-1)
End Function

Pete

-----Original Message-----
From: Nagendra Kumar K [mailto:knagendrak@h...]
Sent: Tuesday, November 19, 2002 12:47 AM
To: professional vb
Subject: [pro_vb] IP Address


Hi Everybody,

How can i find My system IP Address programatically.

Thanx in advance,

Regards

Nag K.

_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8.
http://join.msn.com/?page=features/junkmail




  Return to Index