COMING SOON 🚀

굿

로컬 IP 가지고 오기

· 14년 전 · 1840
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,866
14년 전 조회 1,560
14년 전 조회 2,042
14년 전 조회 2,172
14년 전 조회 1,371
14년 전 조회 2,616
14년 전 조회 2,608
14년 전 조회 2,177
14년 전 조회 2,140
14년 전 조회 1,653
14년 전 조회 2,139
14년 전 조회 2,038
14년 전 조회 1,778
14년 전 조회 1,460
14년 전 조회 3,220
14년 전 조회 2,530
14년 전 조회 1,893
14년 전 조회 2,533
14년 전 조회 1,405
14년 전 조회 1,528
14년 전 조회 2,152
14년 전 조회 2,230
14년 전 조회 1,851
14년 전 조회 1,533
14년 전 조회 1,710
14년 전 조회 1,653
14년 전 조회 2,475
14년 전 조회 2,607
14년 전 조회 2,488
14년 전 조회 1,618
14년 전 조회 2,196
14년 전 조회 2,224
14년 전 조회 2,314
14년 전 조회 4,115
14년 전 조회 1,647
14년 전 조회 2,473
14년 전 조회 1,381
14년 전 조회 1,517
14년 전 조회 1,375
14년 전 조회 1,808
14년 전 조회 2,239
14년 전 조회 1,790
14년 전 조회 1,636
14년 전 조회 1,314
14년 전 조회 2,296
14년 전 조회 1,879
14년 전 조회 1,399
14년 전 조회 2,812
14년 전 조회 1,912
14년 전 조회 1,841
14년 전 조회 1,368
14년 전 조회 2,249
14년 전 조회 3,210
15년 전 조회 1,599
15년 전 조회 1,065
15년 전 조회 2,595
15년 전 조회 2,333
15년 전 조회 1,279
15년 전 조회 1,854
15년 전 조회 2,024
15년 전 조회 1,861
15년 전 조회 1,237
15년 전 조회 1,223
15년 전 조회 1,529
15년 전 조회 1,841
15년 전 조회 1,695
15년 전 조회 1,379
15년 전 조회 1,803
15년 전 조회 1,640
15년 전 조회 1,920
15년 전 조회 1,382
15년 전 조회 1,628
15년 전 조회 1,419
15년 전 조회 1,764
15년 전 조회 1,249
15년 전 조회 2,643
15년 전 조회 1,846
15년 전 조회 3,429
15년 전 조회 1,823
15년 전 조회 1,581
15년 전 조회 1,643
15년 전 조회 1,630
15년 전 조회 1,089
15년 전 조회 1,359
15년 전 조회 1,412
15년 전 조회 2,863
15년 전 조회 1,494
15년 전 조회 3,861
15년 전 조회 1,339
15년 전 조회 1,167
15년 전 조회 1,243
15년 전 조회 2,230
15년 전 조회 1,836
15년 전 조회 1,654
15년 전 조회 1,701
15년 전 조회 1,624
15년 전 조회 1,735
15년 전 조회 1,387
15년 전 조회 1,002
15년 전 조회 1,503