굿

로컬 IP 가지고 오기

· 15년 전 · 1910
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,968
14년 전 조회 1,654
14년 전 조회 2,135
14년 전 조회 2,270
14년 전 조회 1,457
14년 전 조회 2,708
14년 전 조회 2,698
14년 전 조회 2,273
14년 전 조회 2,229
14년 전 조회 1,738
14년 전 조회 2,228
14년 전 조회 2,131
14년 전 조회 1,867
14년 전 조회 1,552
14년 전 조회 3,296
14년 전 조회 2,622
14년 전 조회 1,986
14년 전 조회 2,621
14년 전 조회 1,503
14년 전 조회 1,604
14년 전 조회 2,241
14년 전 조회 2,314
14년 전 조회 1,933
14년 전 조회 1,626
14년 전 조회 1,788
14년 전 조회 1,752
14년 전 조회 2,550
14년 전 조회 2,682
14년 전 조회 2,582
14년 전 조회 1,692
14년 전 조회 2,282
14년 전 조회 2,315
14년 전 조회 2,392
14년 전 조회 4,192
14년 전 조회 1,726
14년 전 조회 2,548
15년 전 조회 1,459
15년 전 조회 1,602
15년 전 조회 1,446
15년 전 조회 1,896
15년 전 조회 2,321
15년 전 조회 1,867
15년 전 조회 1,733
15년 전 조회 1,389
15년 전 조회 2,368
15년 전 조회 1,948
15년 전 조회 1,494
15년 전 조회 2,873
15년 전 조회 1,989
15년 전 조회 1,911
15년 전 조회 1,438
15년 전 조회 2,323
15년 전 조회 3,282
15년 전 조회 1,666
15년 전 조회 1,126
15년 전 조회 2,655
15년 전 조회 2,400
15년 전 조회 1,348
15년 전 조회 1,928
15년 전 조회 2,088
15년 전 조회 1,942
15년 전 조회 1,312
15년 전 조회 1,280
15년 전 조회 1,611
15년 전 조회 1,909
15년 전 조회 1,757
15년 전 조회 1,438
15년 전 조회 1,884
15년 전 조회 1,710
15년 전 조회 1,976
15년 전 조회 1,454
15년 전 조회 1,695
15년 전 조회 1,484
15년 전 조회 1,836
15년 전 조회 1,304
15년 전 조회 2,700
15년 전 조회 1,906
15년 전 조회 3,490
15년 전 조회 1,882
15년 전 조회 1,638
15년 전 조회 1,707
15년 전 조회 1,700
15년 전 조회 1,150
15년 전 조회 1,406
15년 전 조회 1,473
15년 전 조회 2,924
15년 전 조회 1,561
15년 전 조회 3,933
15년 전 조회 1,400
15년 전 조회 1,224
15년 전 조회 1,312
15년 전 조회 2,294
15년 전 조회 1,907
15년 전 조회 1,714
15년 전 조회 1,771
15년 전 조회 1,682
15년 전 조회 1,789
15년 전 조회 1,445
15년 전 조회 1,055
15년 전 조회 1,566