Stuart McLachlan
stuart at lexacorp.com.pg
Tue Jun 30 17:13:21 CDT 2009
clResolve currently returns a string for Adapter 1. It can be easily modified to return arrays of Addresses and Masks for each adapter. (read the comments) -- Stuart On 30 Jun 2009 at 12:43, jwcolby wrote: > Yes, but then you have to do more. IPConfig shows several IP addresses on my work laptop. One is > the wireless, which only works when in range of a wireless network, one is a physical NIC, and one > is a Hamachi IP. There could be even more. On my server I have two physical NICS and in theory > each could have asked for an IP address. > > So would the REAL IP address please stand up. > > John W. Colby > www.ColbyConsulting.com > > > Drew Wutka wrote: > > There are several ways to get your IP address. Two I've used is to use > > a Winsock control, and look at the local host IP. > > > > Another relatively easy way is to dump the results of IPCONFIG to a text > > file. > > > > Create a .bat file (call it iptest.bat) and put the following line in > > it: > > > > Ipconfig >C:\ip.txt > > > > Then using ShellWait (http://mvps.org/access/api/api0004.htm) > > > > Use this function: > > > > Function IPAddresses() As String > > Dim f As Long > > Dim strTemp As String > > Dim strArray() As String > > If Dir("C:\ip.txt") <> "" Then Kill "C:\ip.txt" > > ShellWait "C:\iptest.bat" > > f = FreeFile > > Open "C:\ip.txt" For Binary Access Read As f > > strTemp = Space(LOF(f)) > > Get f, , strTemp > > Close f > > strArray = Split(strTemp, vbCrLf) > > strTemp = "" > > For f = 0 To UBound(strArray) > > If InStr(1, strArray(f), "IPv4", vbTextCompare) > 0 Or InStr(1, > > strArray(f), " IP Address", vbTextCompare) > 0 Then > > strTemp = strTemp & Trim(Mid(strArray(f), InStr(1, strArray(f), > > ":", vbBinaryCompare) + 1)) & ";" > > End If > > Next f > > If Len(strTemp) > 0 Then strTemp = Left(strTemp, Len(strTemp) - 1) > > IPAddresses = strTemp > > End Function > > > > Whalla, IPAddresses will return as a semicolon delimited string. > > (Obviously you could return an array or create a collection too...either > > way....) > > > > Drew > > _______________________________________________ > dba-VB mailing list > dba-VB at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-vb > http://www.databaseadvisors.com >