굿

로컬 IP 가지고 오기

· 14년 전 · 1365
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,359
14년 전 조회 1,061
14년 전 조회 1,486
14년 전 조회 1,653
14년 전 조회 853
14년 전 조회 2,098
14년 전 조회 2,073
14년 전 조회 1,659
14년 전 조회 1,616
14년 전 조회 1,130
14년 전 조회 1,608
14년 전 조회 1,539
14년 전 조회 1,249
14년 전 조회 983
14년 전 조회 2,728
14년 전 조회 2,039
14년 전 조회 1,395
14년 전 조회 2,053
14년 전 조회 930
14년 전 조회 1,030
14년 전 조회 1,650
14년 전 조회 1,755
14년 전 조회 1,359
14년 전 조회 1,049
14년 전 조회 1,215
14년 전 조회 1,155
14년 전 조회 2,001
14년 전 조회 2,127
14년 전 조회 2,002
14년 전 조회 1,132
14년 전 조회 1,706
14년 전 조회 1,757
14년 전 조회 1,857
14년 전 조회 3,629
14년 전 조회 1,179
14년 전 조회 1,979
14년 전 조회 897
14년 전 조회 1,032
14년 전 조회 877
14년 전 조회 1,332
14년 전 조회 1,788
14년 전 조회 1,325
14년 전 조회 1,178
14년 전 조회 835
14년 전 조회 1,815
14년 전 조회 1,385
14년 전 조회 948
14년 전 조회 2,333
14년 전 조회 1,447
14년 전 조회 1,366
14년 전 조회 900
14년 전 조회 1,774
14년 전 조회 2,744
14년 전 조회 1,240
14년 전 조회 637
14년 전 조회 2,200
14년 전 조회 1,959
14년 전 조회 907
14년 전 조회 1,490
14년 전 조회 1,664
14년 전 조회 1,523
14년 전 조회 882
14년 전 조회 851
14년 전 조회 1,160
14년 전 조회 1,482
14년 전 조회 1,340
14년 전 조회 1,022
14년 전 조회 1,450
14년 전 조회 1,296
14년 전 조회 1,570
14년 전 조회 1,018
14년 전 조회 1,255
14년 전 조회 1,054
14년 전 조회 1,416
14년 전 조회 881
14년 전 조회 2,273
14년 전 조회 1,482
14년 전 조회 3,080
14년 전 조회 1,457
14년 전 조회 1,229
14년 전 조회 1,276
14년 전 조회 1,277
14년 전 조회 740
14년 전 조회 1,000
14년 전 조회 1,045
14년 전 조회 2,500
14년 전 조회 1,135
14년 전 조회 3,501
14년 전 조회 972
14년 전 조회 808
14년 전 조회 872
14년 전 조회 1,857
14년 전 조회 1,476
14년 전 조회 1,291
14년 전 조회 1,349
14년 전 조회 1,277
14년 전 조회 1,382
14년 전 조회 1,039
14년 전 조회 642
14년 전 조회 1,157
🐛 버그신고