服务热线:13616026886

技术文档 欢迎使用技术文档,我们为你提供从新手到专业开发者的所有资源,你也可以通过它日益精进

位置:首页 > 技术文档 > JAVA > 新手入门 > 基础入门 > 查看文档

获取本地计算机和其他计算机的mac值的方法


  public function valuesepr(byval rawstring as string, byval sepchar as string) as string
  if instr(1, rawstring, sepchar) <> 0 then
  valuesepr = microsoft.visualbasic.right(rawstring,len(rawstring) - instr(1, rawstring, sepchar))
  else
  valuesepr = rawstring
  end if
  end function
  public function getmac(byval ip as string) as string
  try
  dim dirresults as string
  dim psi as system.diagnostics.processstartinfo = new system.diagnostics.processstartinfo()
  dim proc as new system.diagnostics.process()
  psi.filename = "nbtstat"
  psi.redirectstandardinput = false
  psi.redirectstandardoutput = true
  psi.arguments = "-a " & ip
  psi.useshellexecute = false
  proc = system.diagnostics.process.start(psi)
  dim x as integer = -1
  do until x > -1
  if dirresults <> nothing then
  x = dirresults.trim.tolower.indexof("mac address", 0)
  if x > -1 then
  exit do
  end if
  end if
  dirresults = proc.standardoutput.readline
  loop
  proc.waitforexit()
  getmac = valuesepr(dirresults.trim, "=").trim
  catch err as exception
  response.write(err.message & err.stacktrace)
  end try
  end function

扫描关注微信公众号