굿

로컬 IP 가지고 오기

· 14년 전 · 1801
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,811
14년 전 조회 1,519
14년 전 조회 1,984
14년 전 조회 2,120
14년 전 조회 1,321
14년 전 조회 2,560
14년 전 조회 2,549
14년 전 조회 2,125
14년 전 조회 2,084
14년 전 조회 1,608
14년 전 조회 2,087
14년 전 조회 1,994
14년 전 조회 1,709
14년 전 조회 1,404
14년 전 조회 3,172
14년 전 조회 2,485
14년 전 조회 1,841
14년 전 조회 2,483
14년 전 조회 1,367
14년 전 조회 1,469
14년 전 조회 2,103
14년 전 조회 2,178
14년 전 조회 1,797
14년 전 조회 1,479
14년 전 조회 1,660
14년 전 조회 1,615
14년 전 조회 2,424
14년 전 조회 2,560
14년 전 조회 2,438
14년 전 조회 1,567
14년 전 조회 2,141
14년 전 조회 2,175
14년 전 조회 2,272
14년 전 조회 4,058
14년 전 조회 1,596
14년 전 조회 2,418
14년 전 조회 1,330
14년 전 조회 1,466
14년 전 조회 1,322
14년 전 조회 1,757
14년 전 조회 2,194
14년 전 조회 1,737
14년 전 조회 1,601
14년 전 조회 1,270
14년 전 조회 2,247
14년 전 조회 1,823
14년 전 조회 1,350
14년 전 조회 2,773
14년 전 조회 1,870
14년 전 조회 1,802
14년 전 조회 1,313
14년 전 조회 2,198
14년 전 조회 3,167
14년 전 조회 1,564
14년 전 조회 1,023
14년 전 조회 2,550
14년 전 조회 2,285
14년 전 조회 1,237
14년 전 조회 1,816
14년 전 조회 1,983
14년 전 조회 1,839
14년 전 조회 1,186
14년 전 조회 1,179
15년 전 조회 1,481
15년 전 조회 1,805
15년 전 조회 1,655
15년 전 조회 1,345
15년 전 조회 1,763
15년 전 조회 1,596
15년 전 조회 1,878
15년 전 조회 1,353
15년 전 조회 1,586
15년 전 조회 1,375
15년 전 조회 1,735
15년 전 조회 1,215
15년 전 조회 2,610
15년 전 조회 1,812
15년 전 조회 3,385
15년 전 조회 1,782
15년 전 조회 1,538
15년 전 조회 1,601
15년 전 조회 1,590
15년 전 조회 1,044
15년 전 조회 1,309
15년 전 조회 1,371
15년 전 조회 2,826
15년 전 조회 1,464
15년 전 조회 3,826
15년 전 조회 1,297
15년 전 조회 1,124
15년 전 조회 1,205
15년 전 조회 2,196
15년 전 조회 1,800
15년 전 조회 1,625
15년 전 조회 1,669
15년 전 조회 1,600
15년 전 조회 1,698
15년 전 조회 1,358
15년 전 조회 971
15년 전 조회 1,474