我这里提供一个无需用exe即可打开多个文件的LISP程序:- ;;;=============================================================
- ;;; 通用文件对话框:
- ;;;=============================================================
- (defun C:OpenFile (/ *SCR name code path)
- (or
- (setq *SCR (vlax-create-object "Aec32BitAppServer.AecScriptControl.1"))
- (setq *SCR (vlax-create-object "ScriptControl"))
- )
- (or
- (setq path (strcat (GetSpecialPath 0) "\\System32\\COMCTL32.OCX"))
- (setq path (strcat (GetSpecialPath 0) "\\SysWOW64\\COMCTL32.OCX"))
- )
- (if (and *SCR path)
- (progn
- (vlax-put *SCR 'language "VBScript")
- (setq code
- "Function GetDlg(InitDir,fileName,Filter)
- Set dlg = CreateObject(\"MSComDlg.CommonDialog\")
- dlg.InitDir = InitDir
- dlg.Flags = &H200
- dlg.fileName = fileName
- dlg.Filter = Filter
- dlg.MaxFileSize = 520
- 'dlg.DialogTitle = \"打开文件对话框\"
- 'dlg.Max = 520
- 'dlg.DefaultExt = DefaultExt
- 'dlg.Flags = 18
- dlg.ShowOpen
- GetDlg = dlg.fileName
- End Function"
- )
- (vlax-invoke *SCR 'addcode code)
- (setq name
- (vl-catch-all-apply
- 'vlax-invoke
- (list
- *SCR 'run
- "GetDlg"
- ""
- ""
- "All files(*.*)|*.*|LISP 文件(*.lsp)|*.lsp"
- )
- )
- )
- (vlax-release-object *SCR)
- (if (not (vl-catch-all-error-p name))
- Name
- )
- )
- )
- )
- ;;;Get the system special path
- (defun GetSpecialPath (n / fso path)
- (setq fso (vlax-create-object "Scripting.FileSystemObject"))
- (setq path (vlax-get (vlax-invoke fso 'GetSpecialFolder n) 'path))
- (vlax-release-object fso)
- path
- )
如果读者想了解更多的方式,请参考我的附件。
|