|
-
Nov 18th, 2007, 05:05 AM
#1
Thread Starter
Fanatic Member
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.
-
Nov 18th, 2007, 05:56 AM
#2
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
Last edited by Hack; Nov 18th, 2007 at 05:59 AM.
-
Nov 18th, 2007, 06:01 AM
#3
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.
-
Nov 18th, 2007, 06:14 AM
#4
Thread Starter
Fanatic Member
Re: Best Way To Get MAC, IP And ComputerName
 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.
-
Nov 19th, 2007, 12:38 PM
#5
Frenzied Member
Re: Best Way To Get MAC, IP And ComputerName
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|