Cadence Skill 论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 63|回复: 1

[分享] 根据坛友代码改良获取mac和ip地址的代码

[复制链接]
发表于 7 天前 | 显示全部楼层 |阅读模式
本帖最后由 xieeyawen 于 2025-4-25 17:35 编辑

复制代码
  1. axlCmdRegister("getMacIp" 'getMacIp ?cmdType "generl")
  2. procedure( getMacIp()
  3. prog((p a ln macid ipid)
  4.     system("ipconfig /all > ipdata.txt")
  5.     p = axlDMOpenFile("TEMP" "ipdata.txt", "r") ;从读ipdata.txt这个输入端口获得里面的字符串
  6.    
  7.                 while(gets(ln, p)
  8.                         when(index(ln, "\316\357\300\355\265\330\326\267") || index(ln, "Physical Address" )
  9.                         macid = car(last(parseString(ln, ": \n")))
  10.                             );endwhen
  11.                         when(index(ln, "IPv4 \265\330\326\267") || index(ln, "IPv4 Address" )
  12.                                 a=parseString(ln, ": ( ) \n")
  13.                                 ipid = nth((length(a)-2) a)
  14.                             );endwhen
  15.                             );endwhile
  16.                 axlDMClose(p);必须关掉端口才能输出,不关掉端口就相当于txt文件是空文件
  17.                 deleteFile("./ipdata.txt")
  18.                 println(macid)
  19.                 println(ipid)
  20.     ); end prog
  21. ); end procedure
复制代码

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|网站地图|Cadence Skill 论坛 ( 蜀ICP备13024417号 )

GMT+8, 2025-5-2 11:28 , Processed in 0.445751 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表