| 最初由 playboy 发布[B]能否用vlisp取出硬盘的序列号 [/B]
置顶帖子中有链接
  [php]
;|
函数名: VxGetDriveInfos
功  能: 返回选择磁盘信息
Copyright:   ?001 MENZI ENGINEERING GmbH, Switzerland
参数[类型]:
   Drv = 盘符, 如. "C" 或 "C:" [字串]
返回值[类型]:
  磁盘信息 '(TotalSize FreeSpace DriveType FileSystem SerialNumber ShareName VolumeName) [表]
说明:
  - TotalSize (kB) [实数] 磁盘空间或 network share.
  - FreeSpace (kB) [REAL] 空闲空间 or network share.
  - DriveType [INT]
     0 = "Unknown"
     1 = "Removable"
     2 = "Fixed"
     3 = "Network"
     4 = "CD-ROM"
     5 = "RAM Disk"
  - FileSystem [STR]  磁盘系统格式, 如. "FAT", "NTFS", "CDFS".
  - SerialNumber [INT] Returns the serial number used to uniquely identify a disk volume.
  - ShareName [STR]  Returns the network share name (UNC) for the specified drive. If it's
                     not a network drive, ShareName returns a zero-length string (""). 
  - VolumeName [STR] 卷标
     0 The drive doesn't exist.
     1 The drive is not ready. For removable-media drives and CD-ROM drives,
     VxGetDriveInfos returns -1 when the appropriate media is not inserted
     or not ready for access.
 注意: 需要 ScrRun.dll.
|; 
(defun VxGetDriveInfos (Drv / DrvObj FilSys RetVal)
  (setq        FilSys (vlax-create-object "Scripting.FileSystemObject")
        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-get DrvObj "TotalSize") 1000.0)
                       (/ (vlax-get DrvObj "FreeSpace") 1000.0)
                       (vlax-get DrvObj "DriveType")
                       (vlax-get DrvObj "FileSystem")
                       (vlax-get DrvObj "SerialNumber")
                       (vlax-get DrvObj "ShareName")
                       (vlax-get DrvObj "VolumeName")
                     )
                    )
                  )
                 )
               )
  )
  (if DrvObj
    (vlax-release-object DrvObj)
  )
  (vlax-release-object FilSys)
  RetVal
)[/php]
 |