initial commit
This commit is contained in:
106
ArinNet/ArinNEt.vb
Normal file
106
ArinNet/ArinNEt.vb
Normal file
@@ -0,0 +1,106 @@
|
||||
Imports System.Net.NetworkInformation
|
||||
Imports System.Net
|
||||
Imports System.Net.Dns
|
||||
Public Class MyNet
|
||||
Public Shared Function GetMacAddr() As String '//MAC주소를 볼수있다.
|
||||
Dim computerProperties As IPGlobalProperties = IPGlobalProperties.GetIPGlobalProperties()
|
||||
Dim nics As NetworkInterface() = NetworkInterface.GetAllNetworkInterfaces()
|
||||
Dim adapter As NetworkInterface
|
||||
|
||||
Dim 출력용 As String = vbNullString
|
||||
Dim 카드타입 As String = vbNullString
|
||||
Dim 맥주소 As String = vbNullString
|
||||
Dim 임시맥주소 As String = vbNullString
|
||||
|
||||
For Each adapter In nics
|
||||
Dim properties As IPInterfaceProperties = adapter.GetIPProperties()
|
||||
|
||||
카드타입 = adapter.NetworkInterfaceType.ToString.ToUpper.Trim
|
||||
맥주소 = adapter.GetPhysicalAddress.ToString.ToUpper.Trim
|
||||
|
||||
'//VMWARE NIC 까지 감지를 한다.
|
||||
If 카드타입 = "ETHERNET" Then 임시맥주소 = 맥주소
|
||||
If 카드타입 = "ETHERNET" And 임시맥주소.Substring(0, 11) <> "005056C0000" Then 출력용 = 임시맥주소
|
||||
|
||||
Next adapter
|
||||
|
||||
If 출력용 = vbNullString And 맥주소 = vbNullString Then
|
||||
Return "UNKNOWN"
|
||||
ElseIf 출력용 <> vbNullString Then
|
||||
' MsgBox("맥주소출력")
|
||||
Return (출력용)
|
||||
Else
|
||||
'MsgBox("임시맥주소발견")
|
||||
Return (임시맥주소)
|
||||
End If
|
||||
End Function 'DisplayTypeAndAddress
|
||||
Public Shared Function GetMacArray(Optional ByVal OnlyEthernet As Boolean = True) As NetworkInterface() '//MAC주소를 볼수있다.
|
||||
Dim computerProperties As IPGlobalProperties = IPGlobalProperties.GetIPGlobalProperties()
|
||||
Dim nics As NetworkInterface() = NetworkInterface.GetAllNetworkInterfaces()
|
||||
Dim adapter As NetworkInterface
|
||||
|
||||
Dim 출력용 As String = vbNullString
|
||||
Dim 카드타입 As String = vbNullString
|
||||
Dim 맥주소 As String = vbNullString
|
||||
Dim 임시맥주소 As String = vbNullString
|
||||
|
||||
Dim RetNics() As NetworkInterface = Nothing
|
||||
For Each adapter In nics
|
||||
|
||||
Dim properties As IPInterfaceProperties = adapter.GetIPProperties()
|
||||
|
||||
카드타입 = adapter.NetworkInterfaceType.ToString.ToUpper.Trim
|
||||
맥주소 = adapter.GetPhysicalAddress.ToString.ToUpper.Trim
|
||||
|
||||
|
||||
'//VMWARE NIC 까지 감지를 한다.
|
||||
If adapter.Description.ToUpper.IndexOf("VIRTUALBOX") = -1 AndAlso adapter.Description.ToUpper.IndexOf("VMWARE") = -1 Then
|
||||
|
||||
If OnlyEthernet Then '//이너넷만 할떄
|
||||
If 카드타입 = "ETHERNET" Then
|
||||
If RetNics Is Nothing Then
|
||||
ReDim Preserve RetNics(0)
|
||||
Else
|
||||
ReDim Preserve RetNics(RetNics.GetUpperBound(0) + 1)
|
||||
End If
|
||||
RetNics(RetNics.GetUpperBound(0)) = adapter
|
||||
End If
|
||||
Else '//전부다
|
||||
If RetNics Is Nothing Then
|
||||
ReDim Preserve RetNics(0)
|
||||
Else
|
||||
ReDim Preserve RetNics(RetNics.GetUpperBound(0) + 1)
|
||||
End If
|
||||
RetNics(RetNics.GetUpperBound(0)) = adapter
|
||||
End If
|
||||
|
||||
End If
|
||||
Next
|
||||
Return RetNics
|
||||
End Function 'DisplayTypeAndAddress
|
||||
|
||||
Public Shared Function GetLocalHostIP() As String '//ip주소보기
|
||||
Dim objAddress As IPAddress
|
||||
Dim B(15) As Byte
|
||||
Dim sAns As String
|
||||
Try
|
||||
objAddress = Dns.GetHostEntry(GetHostName).AddressList(0)
|
||||
sAns = objAddress.ToString
|
||||
Catch ex As Exception
|
||||
sAns = ""
|
||||
End Try
|
||||
Return sAns
|
||||
End Function
|
||||
|
||||
Public Shared Function GetLocalHostIPArray() As ArrayList '//ip주소보기
|
||||
|
||||
Dim B(15) As Byte
|
||||
Dim sAns As New ArrayList
|
||||
For Each objAddress As IPAddress In Dns.GetHostEntry(GetHostName).AddressList
|
||||
If IsNumeric(objAddress.ToString.Substring(0, 3)) Then
|
||||
sAns.Add(objAddress.ToString)
|
||||
End If
|
||||
Next
|
||||
Return sAns
|
||||
End Function
|
||||
End Class
|
||||
Reference in New Issue
Block a user