读取硬盘信息
- defun vldos-phyhar (/ ret serx lccon item lox objw)
- (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
- (setq serx (cons (list (vlax-get item 'Tag)
- (vlax-get item 'SerialNumber)
- )
- serx
- )
- )
- )
- (vlax-release-object lox)
- (vlax-release-object lccon)
- (vlax-release-object objW)
- )
- )
- (reverse serx)
- )
- (Defun vldos-driveinfo (Drv Key / pos rtn)
- (if (/= (type key) 'STR)
- (setq rtn (vldos-alldriveinfo drv))
- (if (setq pos (vl-position
- (setq key (strcase key))
- (list "TOTALSIZE" "FREESPACE"
- "DRIVETYPE" "FILESYSTEM"
- "SERIALNUMBER" "SHARENAME"
- "VOLUMENAME"
- )
- )
- )
- (setq rtn (nth pos (vldos-alldriveinfo drv)))
- )
- )
- rtn
- )
- (Defun vldos-alldriveinfo (Drv / DrvObj FilSys RetVal)
- (if (setq
- FilSys (vlax-get-or-create-object "Scripting.FileSystemObject")
- )
- (progn
- (setq RetVal
- (cond
- ((= (vlax-invoke FilSys "DriveExists" Drv) 0) 0)
- ((setq DrvObj (vlax-invoke FilSys "GetDrive" Drv))
- (cond
- ((= (vlax-get DrvObj "IsReady") 0) -1)
- ((list
- (vlax-variant-value
- (vlax-get-property DrvObj "TotalSize")
- )
- (vlax-variant-value
- (vlax-get-property DrvObj "FreeSpace")
- )
- (vlax-get-property DrvObj "DriveType")
- (vlax-get-property DrvObj "FileSystem")
- (vlax-get-property DrvObj "SerialNumber")
- (vlax-get-property DrvObj "ShareName")
- (vlax-get-property DrvObj "VolumeName")
- )
- )
- )
- )
- )
- )
- (if (equal (type DrvObj) 'vla-object)
- (vlax-release-object DrvObj)
- )
- (vlax-release-object FilSys)
- )
- )
- RetVal
- )
|