本帖最后由 尘缘一生 于 2022-4-24 20:25 编辑
根据本坛及搜集的代码:
我的理解是:
1:网卡的MAC是独立唯一的。
3:CPU不能保证唯一
4:硬盘序号:不能保证唯一,格式化后会变化;而物理硬盘序号, LISP取不了,硬盘类型函数也不是唯一的,可以取字符串用。
5:主板类型:不唯一,可以取字符串用。
没有测试,是不是WIN7,WIN10这些都成功否,CAD所有版本都成功否?有用过的,贴上结论。。
- ;|IP是在计算机里地址与MAC地址以MAC地址2表示的,IP是48位的[3]。
- MAC的长度为48位(6个字节),为12个16个典型地址数
- 代表前6位16的EA数字00-16-制造硬件网络的,它由电气与电子协会分配,
- 而代表后6位16的爆系列商号AE-3C-40的网络产品制造(如网卡)
- 只是不改变自己的MAC地址,MAC地址在世界是惟一的
- 用法:(setq str (wdy_mac)) "4C:CC:6A:2B:6E:6E"
- |;
- ( defun wdy_mac ( / macip )
- ( setq WMI ( vlax-create-object "WbemScripting.SWbemLocator" ))
- ( setq SVR ( vlax-invoke WMI 'ConnectServer ))
- ( setq str "Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE" )
- ( setq MAC ( vlax-invoke SVR 'ExecQuery str ))
- ( vlax-for i MAC ( setq s ( cons ( vlax-get i 'MACAddress ) S )))
- ( setq macip ( car s ))
- ( vlax-release-object MAC )
- ( vlax-release-object SVR )
- ( vlax-release-object WMI )
- ;;马西普
- )
- ;;获取CPU序列号 (get_cpu_number) "BFEBFBFF000906E9" CPUID很多电脑都一样
- ( defun get_cpu_number ( / wmi meth1 meth2 cpu_id board_id )
- ( setq wmi ( vlax-create-object "WbemScripting.SWbemLocator" ))
- ( setq meth1 ( vlax-invoke-method wmi 'ConnectServer nil nil nil nil nil nil nil ) )
- ( setq meth2 ( vlax-invoke-method meth1 'ExecQuery "Select * from Win32_Processor" nil nil nil ))
- ( vlax-for n meth2
- ;;(print (vlax-get n 'name)) ;"Intel(R) Core(TM) i5-7400 CPU @ 3.00GHz"
- ( setq cpu_id ( vlax-get n 'ProcessorId ))
- )
- ( foreach obj ( list wmi meth1 meth2 ) ( if obj ( vlax-release-object obj )))
- cpu_id
- )
- ;;获取主板序列号(get_motherboard_number) "G416195192"
- ( defun get_motherboard_number ( / wmi meth1 meth2 board_id )
- ( setq wmi ( vlax-create-object "WbemScripting.SWbemLocator" ))
- ( setq meth1 ( vlax-invoke-method wmi 'ConnectServer nil nil nil nil nil nil nil ) )
- ( setq meth2 ( vlax-invoke-method meth1 'ExecQuery "Select * from Win32_BaseBoard" nil nil nil ))
- ( vlax-for n meth2
- ;; (princ(vlax-get n'name));“产品”
- ( setq board_id ( vlax-get n 'SerialNumber ))
- )
- ( foreach obj ( list wmi meth1 meth2 ) ( if obj ( vlax-release-object obj )))
- board_id
- )
- ;---- 获取硬盘序列号------(find_serialnumber "C:")
- ( defun find_serialnumber (drive / filsys val )
- ( setq filsys ( vlax-create-object "Scripting.FileSystemObject" ))
- (setq val (vlax-invoke filsys “GetDrive”drive))
- ( setq val ( vl-catch-all-apply ' vlax-get ( list val "SerialNumber" )))
- ( vlax-release-object filsys )
- (if(vl-catch-all-error-p val )
- ( setq val nil )
- val
- )
- )
- ;| 返回磁盘的类型
- 用法: (vldos-drivetype DriveLetter[STRING])
- 参数1: 盘符 例如: "C:"
- 说明:
- 返回磁盘的类型
- 返回值:
- [成功]: 磁盘的类型
- [失败]: NIL
- |;
- (Defun vldos-drivetype (drv / Fil drives drive typ rtn)
- (setq rtn "INVALID")
- (if
- (and (setq
- Fil (vlax-get-or-create-object "Scripting.FileSystemObject")
- )
- (equal :vlax-true (vlax-invoke-method Fil 'DriveExists drv))
- )
- (progn
- (setq drives (vlax-get-property Fil 'Drives)
- drive (vlax-get-property drives 'Item drv)
- typ (vlax-get-property drive 'DriveType)
- rtn (nth typ
- (list "UNKNOWN" "REMOVABLE"
- "FIXED" "REMOTE"
- "CDROM" "RAMDISK"
- )
- )
- )
- (vlax-release-object drive)
- (vlax-release-object drives)
- (vlax-release-object Fil)
- )
- )
- rtn
- )
|