當前位置:編程學習大全網 - 源碼下載 - vb6 改語句問題

vb6 改語句問題

Option Explicit

Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)

Public Declare Function GetIpAddrTable Lib "IPHlpApi" (pIPAdrTable As Byte, pdwSize As Long, ByVal Sort As Long) As Long

Const Max_IP = 5

Type IPINFO

dwAddr As Long

dwIndex As Long

dwMask As Long

dwBCastAddr As Long

dwReasmSize As Long

UnUsed1 As Integer

UnUsed2 As Integer

End Type

Type MIB_IPADDRTABLE

dEntrys As Long

mIPInfo(Max_IP) As IPINFO

End Type

Type IP_Array

mBuffer As MIB_IPADDRTABLE

BufferLen As Long

End Type

Public Function GetLocIP() As String

GetLocIP = ""

Dim ret As Long, Tel As Long

Dim bBytes() As Byte

Dim Listing As MIB_IPADDRTABLE

On Error GoTo End1

GetIpAddrTable ByVal 0&, ret, True

If ret <= 0 Then Exit Function

ReDim bBytes(0 To ret - 1) As Byte

GetIpAddrTable bBytes(0), ret, False

CopyMemory Listing.dEntrys, bBytes(0), 4

'MsgBox "找到 " & Listing.dEntrys & " 個IP地址!", 0, "提示"

'For Tel = 0 To Listing.dEntrys - 1

CopyMemory Listing.mIPInfo(0), bBytes(4 + (Tel * Len(Listing.mIPInfo(0)))), Len(Listing.mIPInfo(0)) '拷貝整個結構到Listing

GetLocIP = ConvertAddressToString(Listing.mIPInfo(0).dwAddr)

'MsgBox "IP地址:" & ConvertAddressToString(Listing.mIPInfo(0).dwAddr), 0, "提示"

'Next

'End

End1:

'MsgBox "出錯!", 0, "提示"

'End

End Function

'獲取本地IP地址

Public Function ConvertAddressToString(longAddr As Long) As String

Dim MyByte(3) As Byte

Dim Cnt As Long

CopyMemory MyByte(0), longAddr, 4

For Cnt = 0 To 3

ConvertAddressToString = ConvertAddressToString + CStr(MyByte(Cnt)) + "."

Next Cnt

ConvertAddressToString = Left$(ConvertAddressToString, Len(ConvertAddressToString) - 1)

End Function

  • 上一篇:美容院店慶促銷方案
  • 下一篇:微服務源代碼水龍頭
  • copyright 2024編程學習大全網