Best Way To Get MAC, IP And ComputerName
Hmmm... What would be the best and easiest way to find out the MAC Address, IP address and Computer Name, by knowing any one of these?
For example, If you knew the MAC Address you could find out the IP address and the computer name. Or if you knew the IP Address you could find out the MAC Address and the Computer Name. Remote computers of course on a LAN (Administrator access).
Is this possible to do in VB? Without shelling out to command prompt or the such? Winsock controls are fine.
Re: Best Way To Get MAC, IP And ComputerName
For IP Address, use the Winsock control and do
Code:
MsgBox Winsock1.LocalIP
For Computer Name use
Code:
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" _
(ByVal lpBuffer As String, nSize As Long) As Long
Private Sub Command1_Click()
Dim strBuffer As String
Dim lngBufSize As Long
Dim lngStatus As Long
lngBufSize = 255
strBuffer = String$(lngBufSize, " ")
lngStatus = GetComputerName(strBuffer, lngBufSize)
If lngStatus <> 0 Then
MsgBox ("Computer name is: " & Left(strBuffer, lngBufSize))
End If
End Sub
Re: Best Way To Get MAC, IP And ComputerName
I had to do a search for this MAC address.
Have a look at this thread.
Re: Best Way To Get MAC, IP And ComputerName
Quote:
Originally Posted by Hack
For IP Address, use the Winsock control and do
Code:
MsgBox Winsock1.LocalIP
For Computer Name use
Code:
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" _
(ByVal lpBuffer As String, nSize As Long) As Long
Private Sub Command1_Click()
Dim strBuffer As String
Dim lngBufSize As Long
Dim lngStatus As Long
lngBufSize = 255
strBuffer = String$(lngBufSize, " ")
lngStatus = GetComputerName(strBuffer, lngBufSize)
If lngStatus <> 0 Then
MsgBox ("Computer name is: " & Left(strBuffer, lngBufSize))
End If
End Sub
These are all for the local machine. I'm talking about Remote machines that i have administrator access to over a LAN (Not a domain, a workgroup, but that doesn't really matter).
I'm trying to create a WoL (Wake on LAN) program. The program will use Net View to get a list of the computers and from there get the MAC addresses and IP addresses. But the user can also enter in a MAC address/IP Address/Computer Name and the program will automatically figure out the missing data.
My problem is that i don't understand how to get the data from NetBios and TCP/IP and all that to get the returned MAC address when something is sent to an IP address, or how to convert Computer Names into IP Addresses.
Re: Best Way To Get MAC, IP And ComputerName