找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 582|回复: 1

[转贴]:Which Drives are Available?

[复制链接]

已领礼包: 593个

财富等级: 财运亨通

发表于 2006-6-4 14:56:57 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
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.


  1. ;; Begin Code
  2. (defun GetDrives (/ wshFSO driveObjs)
  3.   (vl-load-com)
  4.   (if (= wshLibImport nil)
  5.     (progn
  6.       (vlax-import-type-library
  7.         :tlb-filename                 "c:\\windows\\system32\\wshom.ocx"
  8.         :methods-prefix                 "wshm-"
  9.         :properties-prefix         "wshp-"
  10.         :constants-prefix         "wshk-"
  11.        )
  12.       (setq wshLibImport T)
  13.     )
  14.   )
  15.   (setq wshFSO (vlax-create-object "Scripting.FileSystemObject"))
  16.   (setq driveObjs (wshp-get-Drives wshFSO))
  17.   (vlax-for driveObj driveObjs
  18.     (progn
  19.       (prompt (strcat "\nDrive Letter: "
  20.                       (vlax-get-property driveObj 'DriveLetter)
  21.               )
  22.       )
  23.       (prompt "\nDrive Type: ")
  24.       (cond
  25.         ((= (vlax-get-property driveObj 'DriveLetter) wshk-CDRom)
  26.          (prompt "CDROM")
  27.         )
  28.         ((= (vlax-get-property driveObj 'DriveLetter) wshk-RamDisk)
  29.          (prompt "Ram Disk")
  30.         )
  31.         ((= (vlax-get-property driveObj 'DriveLetter) wshk-Fixed)
  32.          (prompt "Fixed")
  33.         )
  34.         ((= (vlax-get-property driveObj 'DriveLetter) wshk-Removable)
  35.          (prompt "Removeable")
  36.         )
  37.         ((= (vlax-get-property driveObj 'DriveLetter)
  38.             wshk-UnknownType
  39.          )
  40.          (prompt "Unknown")
  41.         )
  42.       )
  43.       (prompt (strcat "\nIs Ready: "))
  44.       (if (= (vlax-get-property driveObj 'IsReady) :vlax-true)
  45.         (prompt "True")
  46.         (prompt "False")
  47.       )
  48.     )
  49.   )
  50.   (princ)
  51. )
  52. ;; End Code
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
发表于 2006-6-24 01:36:14 | 显示全部楼层
得到系统盘符,真好!
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-11-18 19:29 , Processed in 0.171080 second(s), 34 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表