- (defun Macaddress(/ mac WMIobj serv lox sn)
- (setq mac'())
- (if (SETQ WMIobj(VLAX-CREATE-OBJECT "wbemScripting.SwbemLocator"))
- (progn
- (SETQ serv(VLAX-INVOKE WMIobj'ConnectServer".""\\root\\cimv2"""""""""128 nil)
- lox(vlax-invoke serv'ExecQuery"Select * From Win32_NetworkAdapter "))
- (vlax-for item lox
- (if(and(=(vlax-get item'NetConnectionID)"本地连接")(not(member(setq sn(vlax-get item'MACAddress))mac)))
- (setq mac(cons sn mac))))
- (mapcar 'vlax-release-object (list lox serv WMIobj))))
- (car(reverse mac)))
以上代码来源于网络 |