马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
Which Drives are Available?
From time to time you might want your AutoLISP application to be able to write to a specific drive or drives in a specific order if you are working with a group of users that might do some travelling. If you want to test to see which drives are available through AutoLISP, you could use the function vl-directory-files. This would force you to test each letter combination which can take time and it doesn't tell you if the drive is ready or not. Below is an example using the FSO object to get all the available drives on the machine, and test to see what type of drive it is and if it is ready or not.
- ;; Begin Code
- (defun GetDrives (/ wshFSO driveObjs)
- (vl-load-com)
- (if (= wshLibImport nil)
- (progn
- (vlax-import-type-library
- :tlb-filename "c:\\windows\\system32\\wshom.ocx"
- :methods-prefix "wshm-"
- :properties-prefix "wshp-"
- :constants-prefix "wshk-"
- )
- (setq wshLibImport T)
- )
- )
- (setq wshFSO (vlax-create-object "Scripting.FileSystemObject"))
- (setq driveObjs (wshp-get-Drives wshFSO))
- (vlax-for driveObj driveObjs
- (progn
- (prompt (strcat "\nDrive Letter: "
- (vlax-get-property driveObj 'DriveLetter)
- )
- )
- (prompt "\nDrive Type: ")
- (cond
- ((= (vlax-get-property driveObj 'DriveLetter) wshk-CDRom)
- (prompt "CDROM")
- )
- ((= (vlax-get-property driveObj 'DriveLetter) wshk-RamDisk)
- (prompt "Ram Disk")
- )
- ((= (vlax-get-property driveObj 'DriveLetter) wshk-Fixed)
- (prompt "Fixed")
- )
- ((= (vlax-get-property driveObj 'DriveLetter) wshk-Removable)
- (prompt "Removeable")
- )
- ((= (vlax-get-property driveObj 'DriveLetter)
- wshk-UnknownType
- )
- (prompt "Unknown")
- )
- )
- (prompt (strcat "\nIs Ready: "))
- (if (= (vlax-get-property driveObj 'IsReady) :vlax-true)
- (prompt "True")
- (prompt "False")
- )
- )
- )
- (princ)
- )
- ;; End Code
|