굿

로컬 IP 가지고 오기

· 14년 전 · 1359
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,351
14년 전 조회 1,054
14년 전 조회 1,478
14년 전 조회 1,644
14년 전 조회 842
14년 전 조회 2,091
14년 전 조회 2,067
14년 전 조회 1,653
14년 전 조회 1,607
14년 전 조회 1,122
14년 전 조회 1,600
14년 전 조회 1,530
14년 전 조회 1,243
14년 전 조회 974
14년 전 조회 2,722
14년 전 조회 2,032
14년 전 조회 1,386
14년 전 조회 2,043
14년 전 조회 922
14년 전 조회 1,020
14년 전 조회 1,645
14년 전 조회 1,750
14년 전 조회 1,353
14년 전 조회 1,042
14년 전 조회 1,210
14년 전 조회 1,146
14년 전 조회 1,995
14년 전 조회 2,118
14년 전 조회 1,993
14년 전 조회 1,122
14년 전 조회 1,696
14년 전 조회 1,751
14년 전 조회 1,847
14년 전 조회 3,620
14년 전 조회 1,173
14년 전 조회 1,973
14년 전 조회 889
14년 전 조회 1,022
14년 전 조회 871
14년 전 조회 1,326
14년 전 조회 1,780
14년 전 조회 1,321
14년 전 조회 1,171
14년 전 조회 830
14년 전 조회 1,807
14년 전 조회 1,376
14년 전 조회 938
14년 전 조회 2,324
14년 전 조회 1,440
14년 전 조회 1,360
14년 전 조회 895
14년 전 조회 1,765
14년 전 조회 2,737
14년 전 조회 1,231
14년 전 조회 630
14년 전 조회 2,190
14년 전 조회 1,951
14년 전 조회 898
14년 전 조회 1,482
14년 전 조회 1,657
14년 전 조회 1,514
14년 전 조회 876
14년 전 조회 845
14년 전 조회 1,152
14년 전 조회 1,476
14년 전 조회 1,332
14년 전 조회 1,015
14년 전 조회 1,443
14년 전 조회 1,284
14년 전 조회 1,562
14년 전 조회 1,008
14년 전 조회 1,248
14년 전 조회 1,049
14년 전 조회 1,406
14년 전 조회 871
14년 전 조회 2,266
14년 전 조회 1,477
14년 전 조회 3,076
14년 전 조회 1,449
14년 전 조회 1,221
14년 전 조회 1,268
14년 전 조회 1,270
14년 전 조회 736
14년 전 조회 995
14년 전 조회 1,035
14년 전 조회 2,495
14년 전 조회 1,129
14년 전 조회 3,491
14년 전 조회 965
14년 전 조회 797
14년 전 조회 863
14년 전 조회 1,849
14년 전 조회 1,468
14년 전 조회 1,281
14년 전 조회 1,342
14년 전 조회 1,270
14년 전 조회 1,374
14년 전 조회 1,032
14년 전 조회 636
14년 전 조회 1,147
🐛 버그신고