马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
写程序时常用到这个函数,而又不想用外挂API,就把它写了下来。
- [FONT=courier new]
- (defun HBrowseFolder (msg / index dirlist obj folders path1 dirlist0 path)
- (if (null msg)
- (setq msg "Select folder")
- )
- (setq index T)
- (setq dirlist '() path nil)
- (vl-load-com)
- (setq obj (vlax-create-object "Shell.Application"))
- (setq folders (vlax-invoke-method obj 'BrowseForFolder 0 msg 49))
- (if folders
- (progn
- (setq path1 (vlax-get-property folders 'Title))
- (cond ((eq "桌面" path1)
- (setq path "C:\\WINDOWS\\Desktop\")
- )
- ((eq "我的文档" path1)
- (setq path "C:\\My Documents\")
- )
- (T
- (while index
- (setq path1 (vlax-get-property folders 'Title))
- (if (or (eq "我的电脑" path1) (eq "我的文档" path1))
- (setq index nil)
- (progn
- (setq dirlist (append dirlist (list path1)))
- (setq folders (vlax-get-property folders 'ParentFolder))
- )
- )
- )
- (cond ((eq "我的电脑" path1)
- (setq dirlist (reverse dirlist))
- (setq path2 (car dirlist))
- (setq dirlist0 (cdr dirlist))
- (if dirlist0
- (progn
- (setq path (substr path2 (- (strlen path2) 2) 2))
- (princ "\n")
- (foreach n dirlist0
- (setq path (strcat path "\" n))
- )
- (setq path (strcat path "\"))
- )
- (progn
- (princ "\n")
- (setq path (strcat (substr path2 (- (strlen path2) 2) 2) "\"))
- )
- )
- )
- ((eq "我的文档" path1)
- (setq dirlist (reverse dirlist))
- (setq path "C:\\My Documents")
- (foreach n dirlist
- (setq path (strcat path "\" n))
- )
- (setq path (strcat path "\"))
- )
- (T nil)
- );cond
- )
- );cond
- );PROGN
- nil
- )
- )
- [/FONT]
|