굿

로컬 IP 가지고 오기

· 15년 전 · 1879
Option Explicit
'=========// IP 주소 가져오기 //==========================================================
Public Const ERROR_SUCCESS As Long = 0
Public Const MAX_ADAPTER_NAME_LENGTH As Long = 256
Public Const MAX_ADAPTER_DESCRipTION_LENGTH As Long = 128
Public Const MAX_ADAPTER_ADDRESS_LENGTH As Long = 8


Public Type ip_ADDRESS_STRING
ipAddr(0 To 15) As Byte
End Type


Public Type ip_MASK_STRING
ipMask(0 To 15) As Byte
End Type



Public Type ip_ADDR_STRING
dwNext As Long
ipAddress As ip_ADDRESS_STRING
ipMask As ip_MASK_STRING
dwContext As Long
End Type


Public Type ip_ADAPTER_INFO
dwNext As Long
ComboIndex As Long 'reserved
sAdapterName(0 To (MAX_ADAPTER_NAME_LENGTH + 3)) As Byte
sDescription(0 To (MAX_ADAPTER_DESCRipTION_LENGTH + 3)) As Byte
dwAddressLength As Long
sipAddress(0 To (MAX_ADAPTER_ADDRESS_LENGTH - 1)) As Byte
dwIndex As Long
uType As Long
uDhcpEnabled As Long
CurrentipAddress As Long
ipAddressList As ip_ADDR_STRING
GatewayList As ip_ADDR_STRING
DhcpServer As ip_ADDR_STRING
bHaveWins As Long
PrimaryWinsServer As ip_ADDR_STRING
SecondaryWinsServer As ip_ADDR_STRING
LeaseObtained As Long
LeaseExpires As Long
End Type


Public Declare Function GetAdaptersInfo Lib "iphlpapi.dll" _
(pTcpTable As Any, _
pdwSize As Long) As Long


Public Declare Sub CopyMemory Lib "kernel32" _
Alias "RtlMoveMemory" _
(dst As Any, _
src As Any, _
ByVal bcount As Long)


Public Declare Function DeleteUrlCacheEntry Lib "Wininet.dll" _
Alias "DeleteUrlCacheEntryA" _
(ByVal lpszUrlName As String) As Long


Public Declare Function lstrlenW Lib "kernel32" _
(ByVal lpString As Long) As Long



Public Function LocalipAddress() As String

On Error Resume Next

Dim cbRequired As Long
Dim buff() As Byte
Dim ptr1 As Long
Dim sipAddr As String
Dim Adapter As ip_ADAPTER_INFO

LocalipAddress = ""

Call GetAdaptersInfo(ByVal 0&, cbRequired)

If cbRequired > 0 Then
ReDim buff(0 To cbRequired - 1) As Byte
If GetAdaptersInfo(buff(0), cbRequired) = ERROR_SUCCESS Then
ptr1 = VarPtr(buff(0))
Do While (ptr1 <> 0)
CopyMemory Adapter, ByVal ptr1, LenB(Adapter)
With Adapter
sipAddr = TrimNull(StrConv(.ipAddressList.ipAddress.ipAddr, vbUnicode))
If Len(sipAddr) > 0 Then Exit Do
ptr1 = .dwNext
End With 'With Adapter
Loop 'Do While (ptr1 <> 0
End If 'If GetAdaptersInfo
End If 'If cbRequired > 0

LocalipAddress = sipAddr

End Function

Public Function TrimNull(startstr As String) As String

TrimNull = Left$(startstr, lstrlenW(StrPtr(startstr)))

End Function<div class='small'>[이 게시물은 관리자님에 의해 2011-10-31 16:46:12 기타에서 이동 됨]</div>
|
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

+
제목 글쓴이 날짜 조회
14년 전 조회 1,925
14년 전 조회 1,615
14년 전 조회 2,094
14년 전 조회 2,223
14년 전 조회 1,414
14년 전 조회 2,672
14년 전 조회 2,656
14년 전 조회 2,230
14년 전 조회 2,192
14년 전 조회 1,699
14년 전 조회 2,185
14년 전 조회 2,093
14년 전 조회 1,821
14년 전 조회 1,520
14년 전 조회 3,256
14년 전 조회 2,584
14년 전 조회 1,941
14년 전 조회 2,582
14년 전 조회 1,456
14년 전 조회 1,574
14년 전 조회 2,200
14년 전 조회 2,278
14년 전 조회 1,894
14년 전 조회 1,586
14년 전 조회 1,750
14년 전 조회 1,711
14년 전 조회 2,516
14년 전 조회 2,648
14년 전 조회 2,546
14년 전 조회 1,661
14년 전 조회 2,243
14년 전 조회 2,277
14년 전 조회 2,357
14년 전 조회 4,153
14년 전 조회 1,693
14년 전 조회 2,517
14년 전 조회 1,425
14년 전 조회 1,554
14년 전 조회 1,416
14년 전 조회 1,860
14년 전 조회 2,276
14년 전 조회 1,839
15년 전 조회 1,694
15년 전 조회 1,362
15년 전 조회 2,342
15년 전 조회 1,927
15년 전 조회 1,455
15년 전 조회 2,843
15년 전 조회 1,953
15년 전 조회 1,880
15년 전 조회 1,403
15년 전 조회 2,280
15년 전 조회 3,247
15년 전 조회 1,635
15년 전 조회 1,098
15년 전 조회 2,626
15년 전 조회 2,368
15년 전 조회 1,321
15년 전 조회 1,900
15년 전 조회 2,057
15년 전 조회 1,911
15년 전 조회 1,280
15년 전 조회 1,255
15년 전 조회 1,573
15년 전 조회 1,879
15년 전 조회 1,738
15년 전 조회 1,410
15년 전 조회 1,850
15년 전 조회 1,683
15년 전 조회 1,951
15년 전 조회 1,424
15년 전 조회 1,663
15년 전 조회 1,464
15년 전 조회 1,809
15년 전 조회 1,282
15년 전 조회 2,679
15년 전 조회 1,882
15년 전 조회 3,461
15년 전 조회 1,858
15년 전 조회 1,620
15년 전 조회 1,678
15년 전 조회 1,677
15년 전 조회 1,126
15년 전 조회 1,389
15년 전 조회 1,451
15년 전 조회 2,897
15년 전 조회 1,536
15년 전 조회 3,904
15년 전 조회 1,376
15년 전 조회 1,211
15년 전 조회 1,290
15년 전 조회 2,262
15년 전 조회 1,885
15년 전 조회 1,685
15년 전 조회 1,743
15년 전 조회 1,660
15년 전 조회 1,768
15년 전 조회 1,422
15년 전 조회 1,029
15년 전 조회 1,542