Obtain MAC address based on IP Address

Source: Internet
Author: User

Imports system
Imports system. Diagnostics

Public class macaddress
Public Function getmac (byval IP as string) as string
Dim str1 as string = string. Empty
Try
Dim str2 as string = string. Empty
Dim info1 as processstartinfo = new processstartinfo ()
Dim process1 as process = new process ()

Info1.filename = "NBTSTAT"
Info1.redirectstandardinput = false
Info1.redirectstandardoutput = true
Info1.arguments = "-a" + IP
Info1.useshellexecute = false
Process1 = process. Start (info1)

Dim num1 as integer =-1

While (num1 <=-1)
Num1 = str2.trim (). tolower (). indexof ("MAC address", 0)
If (num1>-1) then
Exit while
End if

Str2 = process1.standardoutput. Readline ()
Process1.waitforexit ()
Str1 = str2.trim ()
End while
Catch ex as exception
Throw ex
End try

Return str1
End Function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.