굿

로컬 IP 가지고 오기

· 15년 전 · 1889
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,935
14년 전 조회 1,620
14년 전 조회 2,102
14년 전 조회 2,231
14년 전 조회 1,423
14년 전 조회 2,679
14년 전 조회 2,666
14년 전 조회 2,236
14년 전 조회 2,200
14년 전 조회 1,704
14년 전 조회 2,189
14년 전 조회 2,097
14년 전 조회 1,828
14년 전 조회 1,524
14년 전 조회 3,266
14년 전 조회 2,594
14년 전 조회 1,950
14년 전 조회 2,592
14년 전 조회 1,466
14년 전 조회 1,581
14년 전 조회 2,208
14년 전 조회 2,289
14년 전 조회 1,907
14년 전 조회 1,594
14년 전 조회 1,757
14년 전 조회 1,717
14년 전 조회 2,529
14년 전 조회 2,654
14년 전 조회 2,555
14년 전 조회 1,672
14년 전 조회 2,251
14년 전 조회 2,290
14년 전 조회 2,369
14년 전 조회 4,164
14년 전 조회 1,703
14년 전 조회 2,525
14년 전 조회 1,437
14년 전 조회 1,565
14년 전 조회 1,423
14년 전 조회 1,872
15년 전 조회 2,283
15년 전 조회 1,844
15년 전 조회 1,705
15년 전 조회 1,369
15년 전 조회 2,349
15년 전 조회 1,932
15년 전 조회 1,469
15년 전 조회 2,846
15년 전 조회 1,962
15년 전 조회 1,890
15년 전 조회 1,416
15년 전 조회 2,286
15년 전 조회 3,256
15년 전 조회 1,645
15년 전 조회 1,103
15년 전 조회 2,630
15년 전 조회 2,377
15년 전 조회 1,327
15년 전 조회 1,908
15년 전 조회 2,066
15년 전 조회 1,916
15년 전 조회 1,285
15년 전 조회 1,261
15년 전 조회 1,581
15년 전 조회 1,887
15년 전 조회 1,741
15년 전 조회 1,416
15년 전 조회 1,854
15년 전 조회 1,687
15년 전 조회 1,958
15년 전 조회 1,428
15년 전 조회 1,666
15년 전 조회 1,465
15년 전 조회 1,815
15년 전 조회 1,284
15년 전 조회 2,682
15년 전 조회 1,888
15년 전 조회 3,467
15년 전 조회 1,861
15년 전 조회 1,623
15년 전 조회 1,685
15년 전 조회 1,680
15년 전 조회 1,128
15년 전 조회 1,391
15년 전 조회 1,454
15년 전 조회 2,900
15년 전 조회 1,540
15년 전 조회 3,908
15년 전 조회 1,382
15년 전 조회 1,215
15년 전 조회 1,293
15년 전 조회 2,265
15년 전 조회 1,890
15년 전 조회 1,690
15년 전 조회 1,749
15년 전 조회 1,664
15년 전 조회 1,773
15년 전 조회 1,428
15년 전 조회 1,033
15년 전 조회 1,546