굿

로컬 IP 가지고 오기

· 14년 전 · 1355
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,341
14년 전 조회 1,047
14년 전 조회 1,472
14년 전 조회 1,639
14년 전 조회 837
14년 전 조회 2,084
14년 전 조회 2,061
14년 전 조회 1,648
14년 전 조회 1,601
14년 전 조회 1,113
14년 전 조회 1,593
14년 전 조회 1,525
14년 전 조회 1,235
14년 전 조회 969
14년 전 조회 2,715
14년 전 조회 2,024
14년 전 조회 1,381
14년 전 조회 2,037
14년 전 조회 916
14년 전 조회 1,016
14년 전 조회 1,639
14년 전 조회 1,744
14년 전 조회 1,346
14년 전 조회 1,036
14년 전 조회 1,204
14년 전 조회 1,137
14년 전 조회 1,986
14년 전 조회 2,115
14년 전 조회 1,986
14년 전 조회 1,118
14년 전 조회 1,690
14년 전 조회 1,744
14년 전 조회 1,842
14년 전 조회 3,613
14년 전 조회 1,167
14년 전 조회 1,966
14년 전 조회 884
14년 전 조회 1,019
14년 전 조회 864
14년 전 조회 1,320
14년 전 조회 1,773
14년 전 조회 1,314
14년 전 조회 1,164
14년 전 조회 822
14년 전 조회 1,801
14년 전 조회 1,373
14년 전 조회 931
14년 전 조회 2,318
14년 전 조회 1,433
14년 전 조회 1,356
14년 전 조회 889
14년 전 조회 1,761
14년 전 조회 2,729
14년 전 조회 1,225
14년 전 조회 623
14년 전 조회 2,184
14년 전 조회 1,947
14년 전 조회 892
14년 전 조회 1,477
14년 전 조회 1,651
14년 전 조회 1,509
14년 전 조회 872
14년 전 조회 839
14년 전 조회 1,141
14년 전 조회 1,470
14년 전 조회 1,326
14년 전 조회 1,009
14년 전 조회 1,438
14년 전 조회 1,279
14년 전 조회 1,552
14년 전 조회 1,006
14년 전 조회 1,242
14년 전 조회 1,041
14년 전 조회 1,400
14년 전 조회 866
14년 전 조회 2,259
14년 전 조회 1,470
14년 전 조회 3,071
14년 전 조회 1,442
14년 전 조회 1,216
14년 전 조회 1,261
14년 전 조회 1,260
14년 전 조회 729
14년 전 조회 988
14년 전 조회 1,028
14년 전 조회 2,487
14년 전 조회 1,122
14년 전 조회 3,485
14년 전 조회 959
14년 전 조회 790
14년 전 조회 857
14년 전 조회 1,842
14년 전 조회 1,461
14년 전 조회 1,276
14년 전 조회 1,338
14년 전 조회 1,266
14년 전 조회 1,367
14년 전 조회 1,025
14년 전 조회 628
14년 전 조회 1,142
🐛 버그신고