本帖最后由 ou67169488 于 2022-9-14 16:04 编辑
- (DEFUN PHYHAR (/ RET SERX OBJW LCCON LOX)
- (VL-LOAD-COM)
- (SETQ SERX '())
- (IF (SETQ OBJW (VLAX-CREATE-OBJECT "wbemScripting.SwbemLocator"))
- (PROGN
- (SETQ LCCON (VLAX-INVOKE OBJW 'CONNECTSERVER "." "\\root\\cimv2" "" ""
- "" "" 128 NIL
- )
- )
- (SETQ LOX (VLAX-INVOKE LCCON 'EXECQUERY "Select SerialNumber,Tag from Win32_PhysicalMedia"))
- (VLAX-FOR ITEM LOX (if (= (VLAX-GET ITEM 'TAG) "\\\\.\\PHYSICALDRIVE0")
- (setq SERX (VLAX-GET ITEM 'SERIALNUMBER))
- )
- )
- (VLAX-RELEASE-OBJECT LOX)
- (VLAX-RELEASE-OBJECT LCCON)
- (VLAX-RELEASE-OBJECT OBJW)
- )
- )
- (PRINC)
- )
上面提取本机硬盘信息,但是在多硬盘的情况下PHYSICALDRIVE0可能会变化,比如昨天PHYSICALDRIVE0是硬盘1,第二天就变成了硬盘2,怎么样做才能保证我们获取到的是主系统盘呢?
|