Results 1 to 5 of 5

Thread: Best Way To Get MAC, IP And ComputerName

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Posts
    540

    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.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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.

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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.

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Posts
    540

    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.

  5. #5
    Frenzied Member
    Join Date
    Jul 2007
    Posts
    1,306
    IIF(Post.Rate > 0 , , )

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width