굿

로컬 IP 가지고 오기

· 14년 전 · 1346
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,337
14년 전 조회 1,040
14년 전 조회 1,466
14년 전 조회 1,631
14년 전 조회 833
14년 전 조회 2,078
14년 전 조회 2,052
14년 전 조회 1,641
14년 전 조회 1,594
14년 전 조회 1,103
14년 전 조회 1,585
14년 전 조회 1,516
14년 전 조회 1,226
14년 전 조회 958
14년 전 조회 2,703
14년 전 조회 2,013
14년 전 조회 1,371
14년 전 조회 2,028
14년 전 조회 906
14년 전 조회 1,006
14년 전 조회 1,633
14년 전 조회 1,738
14년 전 조회 1,336
14년 전 조회 1,027
14년 전 조회 1,194
14년 전 조회 1,127
14년 전 조회 1,979
14년 전 조회 2,104
14년 전 조회 1,975
14년 전 조회 1,111
14년 전 조회 1,683
14년 전 조회 1,736
14년 전 조회 1,834
14년 전 조회 3,602
14년 전 조회 1,159
14년 전 조회 1,960
14년 전 조회 877
14년 전 조회 1,014
14년 전 조회 856
14년 전 조회 1,314
14년 전 조회 1,767
14년 전 조회 1,306
14년 전 조회 1,158
14년 전 조회 814
14년 전 조회 1,795
14년 전 조회 1,364
14년 전 조회 925
14년 전 조회 2,310
14년 전 조회 1,425
14년 전 조회 1,347
14년 전 조회 883
14년 전 조회 1,752
14년 전 조회 2,721
14년 전 조회 1,220
14년 전 조회 615
14년 전 조회 2,180
14년 전 조회 1,939
14년 전 조회 886
14년 전 조회 1,470
14년 전 조회 1,644
14년 전 조회 1,502
14년 전 조회 865
14년 전 조회 832
14년 전 조회 1,136
14년 전 조회 1,464
14년 전 조회 1,317
14년 전 조회 1,001
14년 전 조회 1,429
14년 전 조회 1,273
14년 전 조회 1,544
14년 전 조회 996
14년 전 조회 1,233
14년 전 조회 1,034
14년 전 조회 1,391
14년 전 조회 857
14년 전 조회 2,252
14년 전 조회 1,461
14년 전 조회 3,064
14년 전 조회 1,436
14년 전 조회 1,208
14년 전 조회 1,251
14년 전 조회 1,250
14년 전 조회 721
14년 전 조회 983
14년 전 조회 1,021
14년 전 조회 2,478
14년 전 조회 1,113
14년 전 조회 3,477
14년 전 조회 948
14년 전 조회 783
14년 전 조회 849
14년 전 조회 1,833
14년 전 조회 1,452
14년 전 조회 1,265
14년 전 조회 1,328
14년 전 조회 1,255
14년 전 조회 1,358
14년 전 조회 1,013
14년 전 조회 620
14년 전 조회 1,133
🐛 버그신고