本帖最后由 作者 于 2007-7-22 15:18:43 编辑
怎样写关于读取硬盘号的LISP函数 (Defun C:phyhar (/ code code Drives lstSer StrDrive SerialNumber) (vl-load-com) (setq code "C") (setq FSO (vlax-create-object "Scripting.FileSystemObject") Drives (vlax-get-property FSO "Drives") ) (setq lstSer '()) ;; iterator the HardDisk for the SerialNumber . (repeat (vlax-get-property Drives "Count") (setq StrDrive (strcat code ":")) (if (and (setq Drive (vl-catch-all-apply 'vlax-get-property (list Drives "Item" StrDrive))) (not (vl-catch-all-error-p Drive)) (vlax-property-available-p Drive "DriveType") (equal (vlax-get-property Drive "DriveType") 2) (vlax-property-available-p Drive "SerialNumber") (setq SerialNumber (vlax-get-property Drive "SerialNumber")) ) (setq SerialNumber (rtos SerialNumber 2 0) lstSer (cons (list StrDrive SerialNumber) lstSer) ) ) (setq code (chr (1+ (ascii code)))) ) ;; relese object . (vl-catch-all-apply 'vlax-release-object (list FSO)) (vl-catch-all-apply 'vlax-release-object (list Drives)) ;; return the value . (princ(reverse lstSer)) )
在CAD下加载输入PHYHAR命令 得到如结果: ((C: 819512431) (D: 1869301091) (E: 1908366405) (F: 1951228752)) 现在我再想写个函数提取其中819512431这个硬盘号,怎么写呀 请高手多指点,十分感谢!急呀!我QQ:83856718
|