|
|
|
|
|
Dicas
|
|
Visual Basic (Redes/Comunicações)
|
|
|
Título da Dica: IP sem WinSock
|
|
|
|
Postada em 15/2/2008 por Fernando
fernando@shift.com.br
'no modulo declare Private Declare Function GetIpAddrTable_API Lib "IpHlpApi" Alias "GetIpAddrTable" (pIPAddrTable As Any, pdwSize As Long, ByVal bOrder As Long) As Long
Public Function GetIpAddrTable() As String Dim Buf(0 To 511) As Byte Dim BufSize As Long: BufSize = UBound(Buf) + 1 Dim rc As Long rc = GetIpAddrTable_API(Buf(0), BufSize, 1) If rc <> 0 Then Err.Raise vbObjectError, , "GetIpAddrTable failed with return value " & rc Dim NrOfEntries As Integer: NrOfEntries = Buf(1) * 256 + Buf(0) If NrOfEntries = 0 Then GetIpAddrTable = Array(): Exit Function ReDim IpAddrs(0 To NrOfEntries - 1) As String Dim i As Integer For i = 0 To NrOfEntries - 1 Dim j As Integer, s As String: s = "" For j = 0 To 3: s = s & IIf(j > 0, ".", "") & Buf(4 + i * 24 + j): Next IpAddrs(i) = s Next GetIpAddrTable = IpAddrs(2) End Function
'para chamar a função Dim IpLocal as String IpLocal = GetIpAddrTable
Abraços
|
|
|
|
|