;;;=============================================================;;; ActiveX和脚本技术及其应用 ;;; ------------------------------------------------------------;;; 此文提到的程序,都通过验证。不排除某些特殊情况下不能通过。另;;; 外,有些地方虽然是C:开头的函数,但是不建议运行整段程序,否则;;; 可能无法通过。之所以列出来,仅仅为提供思路和举例说明。 ;;;=============================================================(vl-load-com);;;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 );;;两种方法有不同。(defun GetSpecialFolder (name / wsh spec folder) (setq wsh (vlax-create-object "wscript.shell")) (setq Spec (vlax-get wsh 'SpecialFolders)) (setq folder (vlax-invoke spec 'item name)) (vlax-release-object spec) (vlax-release-object wsh) folder );;;Get some special folders 用来获取计算机的所有特别路径(defun GetAllSpecialFolders (/ wsh spec count folders) (setq wsh (vlax-create-object "wscript.shell")) (setq Spec (vlax-get wsh 'SpecialFolders)) (setq count (vlax-invoke spec 'count)) (repeat count (setq count (1- count)) (setq folders (cons (vlax-invoke spec 'item count) folders)) ) (vlax-release-object spec) (vlax-release-object wsh) folders );;;=============================================================;;;import type library 获得输人类型库 ;;;=============================================================(defun C:GetLibrary (/ path) (setq path (strcat (GetSpecialPath 1) "\\wshom.ocx")) ;for Wscript.shell (if (not wc-Alias) (vlax-import-type-library :tlb-filename path :methods-prefix "wm-" :properties-prefix "wp-" :constants-prefix "wc-" ) ) (setq path (strcat (GetSpecialPath 1) "\\msscript.ocx")) ;for ScriptControl (if (not sc-Connected) (vlax-import-type-library :tlb-filename path :methods-prefix "sm-" :properties-prefix "sp-" :constants-prefix "sc-" ) ) (setq path (strcat (getSpecialPath 1) "\\scrrun.dll")) ;for Shell.application (if (not fc-Alias) (vlax-import-type-library :tlb-filename path :methods-prefix "fm-" :properties-prefix "fp-" :constants-prefix "fc-" ) ) (setq path (strcat (getSpecialPath 1) "\\shell32.dll")) ;for Shell.application (if (not ac-ssfwindows) (vlax-import-type-library :tlb-filename path :methods-prefix "am-" :properties-prefix "ap-" :constants-prefix "ac-" ) ) ;;(VL-REGISTRY-READ "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Office\\14.0\\Word\\InstallRoot") (if (not mswc-wd70) ; check for a WinWord constant (vlax-import-type-library :tlb-filename "C:\\Program Files\\Microsoft Office\\Office14\\msword.olb" ;依据自己的安装路径和版本 :methods-prefix "mswm-" :properties-prefix "mswp-" :constants-prefix "mswc-" ) ));;;=============================================================;;; 利用wscript发送键 ;;;=============================================================(defun c:sendkey () (setq wsh (vlax-create-object "WScript.Shell")) ;;Send keys (wm-sendkeys wsh "C{ENTER}0,0{ENTER}100{ENTER}") ;Draw a circle in CAD. 在CAD里面画一个圆 (WM-SENDKEYS wsh (chr 1)) ;Ctrl + A (WM-SENDKEYS wsh (chr 15)) ;Ctrl + O (WM-SENDKEYS wsh (chr 22)) ;Ctrl + V ;; if your system can read Chinese,these will be interesting. (WM-SENDKEYS wsh "赌") ;Open My computer 打开我的电脑 (WM-SENDKEYS wsh "品") ;Open Calc.exe 打开计算器 (WM-SENDKEYS wsh "血") ;Open Search 打开搜索 (WM-SENDKEYS wsh "恋") ;Open Media Player 打开媒体播放器 (WM-SENDKEYS wsh "爽") ;Open homepage 打开主页 (vlax-release-object wsh) (princ));;;=============================================================;;; 测试scriptcontrol,wscript.shell ;;;=============================================================(defun C:test1 (/ scr wsh DESKTOPPATH ENV I LINK OBJENV OBJPRO OBJVAR OBJWMI SPEC STR URL) (C:GetLibrary) ;;Create a scriptControl instance. 创建脚本对象 ;;(setq scr (vlax-create-object "MSScriptControl.ScriptControl.1")) (setq scr (vlax-create-object "ScriptControl")) ;;put its language as "VBS" 赋予脚本语言为vbs (vlax-put Scr "language" "vbs") (sp-put-Language scr "VBS") ;the same as upper 两者方法相同 ;;Create a Wscript.shell 创建Wscript.shell对象 (setq wsh (vlax-create-object "WScript.Shell")) ;;Pop up a simple box 简单的对话框 (wm-Popup wsh "Hello,World!") ;;Input box 输入框 (vlax-invoke scr 'ExecuteStatement "str=InputBox(\"Input your string:\", \"Input Box\")") (sm-ExecuteStatement scr "str=InputBox(\"Input your string:\", \"Input Box\")") ;;Eval a WSH variale. 对脚本变量的求值 (vlax-invoke scr 'eval "str") ;get the string you input. (princ (strcat "\n脚本中str的数值是:" (sm-eval scr "str"))) ;;Create a URL shortcut 创建一个快捷链接 (setq Spec (wp-get-SpecialFolders wsh)) (setq deskTopPath (wm-item spec "DeskTop")) (setq url (wm-CreateShortcut wsh (strcat deskTopPath "\\MyTest.URL"))) (wp-put-TargetPath url "http://www.theswamp.org/") (wm-save url) ;;Create a shortcut and assign a shortcut key 创建快捷方式或者快捷键 (setq link (wm-CreateShortcut wsh (strcat DeskTopPath "\\MyTest.lnk"))) (wp-put-TargetPath link "http://www.theswamp.org/") (wp-put-WindowStyle link 1) (wp-put-Hotkey link "Ctrl+Alt+T") (wp-put-IconLocation link "shell32.dll,14") (wp-put-Description link "The desciption for Mytest") (wp-put-WorkingDirectory link "c:\\") (wm-save link) ;;Run command 运行命令 (wm-run wsh "cmd.exe /C dir c:\\temp\\*.* /a /s >>c:\\1.txt") ;;Get a WshEnvironment 获取系统环境变量 (Setq env (wp-get-Environment wsh "System")) ;;Get the special path of system. 获取某些特殊路径 (alert (wp-get-item env "WINDIR")) (alert (wm-ExpandEnvironmentStrings wsh "%windir%")) (alert (wp-get-Item env "TMP")) (alert (wp-get-Item env "TEMP")) ;;Add or remove an Environment variable 添加或者移除环境变量 (alert "Add a test var to the system!") (wp-put-item env "TestVar" "Windows Script Host") (alert "Remove the test var from the system!") (wm-remove env "TestVar") ;;List the Environment variables 列表环境变量 (setq i 0) (repeat (wm-count env) (princ (wp-get-item env i)) ;wouldn't display 不会显示 (setq i (1+ i)) ) ;;Registration table ;;Regread ,RegWrite,RegDelete 读写注册表 (vlax-invoke wsh 'RegRead "HKCU\\Software\\AutoDesk\\AutoCAD\\R16.2\\curver") ;ensure your CAD is autocad 2006 根据自己的CAD版本确定 ;;Maybe you would like this way: 利用vbs的脚本来获取 (setq str "Set WshShell = CreateObject(\"WScript.Shell\") Msgbox \"Environment.item: \"& WshShell.Environment.item(\"WINDIR\") Msgbox \"ExpandEnvironmentStrings: \"& WshShell.ExpandEnvironmentStrings(\"%windir%\") set oEnv=WshShell.Environment(\"System\") Msgbox \"Adding ( TestVar=Windows Script Host ) to the System type environment\" oEnv(\"TestVar\") = \"Windows Script Host\" Msgbox \"removing ( TestVar=Windows Script Host ) from the System type environment\" oEnv.Remove \"TestVar\" for each sitem in oEnv strval=strval & sItem & vbcrlf next Msgbox \"System Environment:\" & vbcrlf & vbcrlf & strval strval=\"\"' set oEnv=WshShell.Environment(\"Process\") for each sitem in oEnv strval=strval & sItem & vbcrlf next Msgbox \"Process Environment:\" & vbcrlf & vbcrlf & strval strval=\"\" set oEnv=WshShell.Environment(\"User\") for each sitem in oEnv strval=strval & sItem & vbcrlf next Msgbox \"User Environment:\" & vbcrlf & vbcrlf & strval strval=\"\" set oEnv=WshShell.Environment(\"Volatile\") for each sitem in oEnv strval=strval & sItem & vbcrlf next Msgbox \"Volatile Environment:\" & vbcrlf & vbcrlf & strval strval=\"\" set oEnv = nothing set WshShell = nothing " ) (vlax-invoke Scr 'ExecuteStatement str) ;;Get some information from OS 获取操作系统信息 (setq str "Set mc=GetObject(\"Winmgmts:\")") (SM-EXECUTESTATEMENT scr str) (setq objWMI (vla-eval scr "mc")) ;;another way 另一种方法 (setq objENv (vlax-invoke objWMI 'get "Win32_Environment")) (setq objvar (vlax-invoke objenv 'SpawnInstance_)) (setq objPro (vlax-get objvar 'Properties_)) ;; get more usage 获取更多用法 (vlax-dump-object objvar T) (vlax-for n objpro (vlax-dump-object n T) ) ;; 测试环境比变量的查询、增加和删除 (vlax-put (vlax-invoke objpro 'item "name") 'value "TestValue") (vlax-put (vlax-invoke objpro 'item "UserName") 'value "System") (vlax-put (vlax-invoke objpro 'item "VariableValue") 'value "This is a test") (vlax-put objvar 'name "MyTest") (vlax-put objvar 'UserName "System") (vlax-put objvar 'VariableValue "This is a test") (vlax-invoke objvar 'put_) (vlax-for obj (vlax-invoke objWMI 'ExecQuery "Select * from Win32_Environment Where Name = 'Path'") (princ (strcat "\nName is:" (vlax-get obj 'name))) (princ (strcat "\nUser Name is:" (vlax-get obj 'username))) (princ (strcat "\nVariable value is:" (vlax-get obj 'variablevalue))) ) ;; 最终释放 (and ObjPro (vlax-release-object ObjPro)) (and objvar (vlax-release-object objvar)) (and objENv (vlax-release-object objENv)) (and objWMI (vlax-release-object objWMI)) (and scr (vlax-release-object scr)) (and wsh (vlax-release-object wsh)) (princ));;;=============================================================;;; 用WMI来获取系统软硬件等信息. ;;;=============================================================(defun C:Test2 (/ SVR WMI) ;; ProcessorId 获取处理器ID的子程序 (defun C:CPUID (/ WMI SVR CPU s) (setq WMI (vlax-create-object "WbemScripting.SWbemLocator")) (setq SVR (VLAX-INVOKE WMI 'ConnectServer)) (setq CPU (vlax-invoke SVR 'InstancesOf "Win32_Processor")) (vlax-for item CPU (setq s (cons (vlax-get item 'ProcessorId) s)) ) (vlax-release-object CPU) (vlax-release-object SVR) (vlax-release-object WMI) (reverse s) ) (defun CPUID(/ scr str objwmi objcpu) (setq scr (vlax-create-object "ScriptControl")) (vlax-put scr 'language "VBS") (setq str "Set mc=GetObject(\"Winmgmts:\")") (vlax-invoke scr 'EXECUTESTATEMENT str) (setq objWMI (vla-eval scr "mc")) (setq objCPU (vlax-invoke objWMI 'InstancesOF "Win32_Processor")) (vlax-for obj objCPU (alert (vlax-get obj 'ProcessorId)) ) (vlax-release-object objCPU) (vlax-release-object objWMI) (vlax-release-object scr) (princ) ) ;;可通过下面两种方式获得ISWbemServicesEx实例:(我已注释掉方式1) ;;(setq str "Set mc=GetObject(\"Winmgmts:\")") ;;(SM-EXECUTESTATEMENT scr str) ;;(setq SVR (vla-eval scr "mc")) (setq WMI (vlax-create-object "WbemScripting.SWbemLocator")) (setq SVR (VLAX-INVOKE WMI 'ConnectServer)) ;;you can get more details by these ways: (foreach p (list "Win32_ComputerSystem" "Win32_Service" "Win32_LogicalMemoryConfiguration" "Win32_Process" "Win32_Processor" "Win32_OperatingSystem" "Win32_WMISetting" "__NAMESPACE" "win32_baseboard" "win32_videocontroller" "win32_DiskDrive" "win32_physicalMemory" "Win32_Environment" "Win32_ProcessStartTrace" "Win32_PnpDevice" "Win32_SoundDevice" "Win32_ProductCheck" "Win32_NetworkAdapter" "Win32_CDROMDrive" "Win32_DesktopMonitor" "Win32_NetworkAdapterConfiguration" ) (vlax-for n (vlax-invoke SVR 'InstancesOf p) (alert (vlax-invoke n 'GetObjectText_)) ) ) ;;Just collect some simple information: ;;Get User name.用户名 (vlax-for n (vlax-invoke SVR 'InstancesOf "Win32_ComputerSystem") (princ "\nUser name is:") (princ (vlax-get n 'name)) ) ;;Get the running process 进程 (vlax-for n (vlax-invoke SVR 'InstancesOf "Win32_Process") (princ (strcat "\n" (vlax-get n 'name))) ) ;;Get the information of CPU 处理器 (vlax-for n (vlax-invoke SVR 'InstancesOf "Win32_Processor") (princ (vlax-get n 'name)) ) ;;Get the Total of Computer System 计算机系统 (vlax-for n (vlax-invoke SVR 'InstancesOf "Win32_ComputerSystem") (princ (/ (read (vlax-get n 'TotalPhysicalMemory)) 1048576)) (princ "M") ) ;;Get the information of physical memory 物理内存 (vlax-for n (vlax-invoke SVR 'InstancesOf "Win32_PhysicalMemory") (princ "\n") (princ (vlax-get n 'Description)) (princ "\n") (princ (vlax-get n 'DeviceLocator)) (princ "\n") (princ (vlax-get n 'speed)) ) ;;Get the information of Video Controller 显卡 (vlax-for n (vlax-invoke SVR 'InstancesOf "Win32_VideoController") (princ "\n") (princ (vlax-get n 'Caption)) (princ "\n") (princ (vlax-get n 'VideoModeDescription)) ) ;;Get the information of Disk drive 磁盘 (vlax-for n (vlax-invoke SVR 'InstancesOf "Win32_DiskDrive") (princ "\nThe Caption is:") (princ (vlax-get n 'Caption)) (princ "\nThe size is:") (princ (/ (read (vlax-get n 'size)) 1073741824)) (princ "G") ) ;;Get the information of Sound Device 声卡 (vlax-for n (vlax-invoke SVR 'InstancesOf "Win32_SoundDevice") (princ "\nThe product Name is:") (princ (vlax-get n 'ProductName)) ) ;;Network Adapter 网卡配置信息 (princ "\nThe Mac Address is: ") (vlax-for obj (vlax-invoke SVR 'InstancesOF "Win32_NetworkAdapterConfiguration") (if(/= (vlax-get obj 'IPEnabled) 0) (princ (vlax-get obj 'MacAddress)) ) ) ;;Get the information of Network Adapter 网络适配器 (vlax-for n (vlax-invoke SVR 'InstancesOf "Win32_NetworkAdapter") (princ "\nThe Description is:") (princ (vlax-get n 'Description)) (princ "\nThe MAC address is") (princ (vlax-get n 'MACAddress)) ) ;;Get the information of FloppyDrive --haha,do you have a floppy drive? 软驱 (vlax-for n (vlax-invoke SVR 'InstancesOf "Win32_FloppyDrive") (princ "\nThe caption is:") (princ (vlax-get n 'Caption)) ) ;;Get the information of CD/DVD ROM 光驱 (vlax-for n (vlax-invoke SVR 'InstancesOf "Win32_CDROMDrive") (princ "\nThe Drive name is:") (princ (vlax-get n 'Name)) (princ "\nThe description is:") (princ (vlax-get n 'Description)) ) ;;Get the information of Desktop Monitor 显示器 (vlax-for n (vlax-invoke SVR 'InstancesOf "Win32_DesktopMonitor") (princ "\nScreen Width:") (princ (vlax-get n 'ScreenWidth)) (princ "\nScreen Height:") (princ (vlax-get n 'ScreenHeight)) ) ;;Printer 打印机 (vlax-for obj (vlax-invoke SVR 'InstancesOF "Win32_Printer") (vlax-dump-object obj T) (alert (vlax-get obj 'Name)) (vlax-get obj 'PaperSizesSupported) (alert (vlax-invoke obj 'GetObjectText_)) ) (vlax-release-object SVR) (vlax-release-object WMI) (princ));;;=============================================================;;; Shell.Application的一些例子函数和应用 ;;; some small applications of Shell.application ;;;=============================================================(defun C:test3 (/ *SHELL BIN EXEC FILE MARK OPFLAG PATH ROOT) (setq path (strcat (getSpecialPath 1) "\\shell32.dll")) (if (not ac-ssfwindows) (vlax-import-type-library :tlb-filename path :methods-prefix "am-" :properties-prefix "ap-" :constants-prefix "ac-" ) ) (setq *SHELL (vlax-create-object "Shell.Application")) (am-CascadeWindows *SHELL) ;Cascade Windows 层叠窗口 (am-ControlPanelItem *SHELL "inetcpl.cpl" ) ;Open a control panel(internet) 打开控制面板 (am-settime *SHELL) ;Open the time setting dialog 打开时间和日期设置对话框 (am-TrayProperties *SHELL) ;日期和时间 属性 (am-explore *SHELL "c:\\") ;Explore C: 打开 C 盘 (am-FindComputer *SHELL) ;Search a computer 搜索计算机 (am-findPrinter *SHELL "canno") ;Search a printer 搜索打印机 (am-GetSystemInformation *SHELL "ProcessorSpeed") ;Get the processor speed(in windows 7 or vista) 处理器速度 (am-GetSystemInformation *SHELL "PhysicalMemoryInstalled") ;the capacity of physical memory 物理内存容量 (am-GetSystemInformation *SHELL "IsOS_Professional") ;Check the Operating system version is professional or not. 是否是专业版 (am-filerun *SHELL) ;Open "Windows Run" 打开运行窗口 (am-ShutdownWindows *SHELL) ;Shutdown windows 关机对话框 (am-findfiles *SHELL) ;Searh files 搜索文件 (am-toggledesktop *SHELL) ;toggle desktop 显示桌面 (am-IsServiceRunning *SHELL "Spooler") ;check a service is running or not(e.g,spooler service) 检测某项服务(打印机)是否在运行 (am-WindowsSecurity *SHELL) ;Windows Security Windows安全 (am-AddToRecent *SHELL "c:\\1.txt") ;Add to recent 添加到最近打开文档 (am-namespace *SHELL "c:\\") ;return a folder object 返回所打开的Folder对象 (am-BrowseForFolder *SHELL ;BrowseForFolder 选择文件夹对话框 (vla-get-hwnd (vlax-get-acad-object) ) "Select a folder" 64 ) (am-BrowseForFolder shapp 0 "我的电脑" 16 17) ;打开文件浏览对话框,并获得文件夹对象 (am-open *SHELL "c:\\") ;Open a folder. 打开某个目录 ;;Here is an example,to get some details of a picture file. 获得图像的详细信息,包括分辨率等等 (defun GetInfoOfPic(*SHELL path name / info root file i l) (setq root (am-namespace *SHELL path)) (setq file (am-ParseName root name)) (setq i 0) (repeat 256 (setq info (am-GetDetailsOf root file i)) (if (/= info "") (progn (princ (strcat "\nIndex " (itoa i) ": " info)) (setq l (cons info l)) ) ) (setq i (1+ i)) ) (reverse l) ) (getInfoOfPic *SHELL "D:\\temp" "1.jpg") ;; 下面是一个小小的程序,用来获得某个目录下的文件夹和文件名 ;; Here is a program to get a foler and its subdirectories and files name. (defun BrowseFolder(*SHELL fp / root items count i item path name) (setq root (am-namespace *SHELL fp)) (setq items (am-items root)) (setq count (ap-get-Count items)) (setq i 0) (repeat count (setq item (am-item items i)) (setq path (ap-get-path item)) (setq name (ap-get-name item)) (if (= (ap-get-IsFolder item) :vlax-true) (progn (princ (strcat "\n---Folder:" path)) (BrowseFolder *SHELL path) ) (princ (strcat "\nFile name:" name)) ) (setq i (1+ i)) ) ) (BrowseFolder *SHELL "C:\\Program Files (x86)\\AutoCAD 2006") ;此处路径根据你的情况而定 ;;to Create a new foler 创建文件夹 (setq root (am-namespace *SHELL "d:\\")) (am-NewFolder root "Test") ;;to copy a file 拷贝文件 (setq file (am-ParseName root "1.jpg")) (am-copyhere (am-namespace *SHELL "c:\\") file 16) ;;to move a file (e.g,move a file to recyle bin) 移动一个文件 (setq opFlag 1108) ;FOF_ALLOWUNDO | FOF_SIMPLEPROGRESS | FOF_NOCONFIRMATION (setq bin (am-namespace *SHELL 10)) ;Recyle bin (am-movehere bin "c:\\1.dwg" opFlag) ;move to recyle bin ;;Get some special folder. 得到某些特殊文件夹 (am-NameSpace *SHELL "shell:PrintersFolder") (am-NameSpace *SHELL "shell:personal") (am-NameSpace *SHELL "shell:drivefolder") ;;(am-ShowBrowserBar *SHELL "{C4EE31F3-4768-11D2-BE5C-00A0C9A83DA1}" :vlax-true);;??? ;;Verbs and File Associations 执行跟一个文件或者文件夹相关联的 (am-doit (am-item (am-verbs (ap-get-self root)) 0)) (am-doit (am-item (am-verbs file) 0)) ;;Open some control panel options (am-ShellExecute *SHELL "Explorer.exe" "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}") ;Open "My Computer" 打开我的电脑 (am-ShellExecute *SHELL "Rundll32.exe" "shell32.dll,Control_RunDLL netcpl.cpl,,1") ; (am-ShellExecute *SHELL "Rundll32.exe" "shell32.dll,Control_RunDLL sysdm.cpl,,2" ) ;Open "System Property" 系统属性 (am-ShellExecute *SHELL "Rundll32.exe" "shdocvw.dll,OpenURL %l") ;Internet shortcut ,IE8,IE7? Internet 快捷方式 (am-ShellExecute *SHELL "Rundll32.exe" "msconf.dll,OpenConfLink") ;SpeedDial (am-ShellExecute *SHELL "Rundll32.exe" "zipfldr.dll,RouteTheCall") ;Zip file 压缩文件夹shdocvw.dll,OpenURL (am-ShellExecute *SHELL "Rundll32.exe" "netplwiz.dll,UsersRunDll") ;user account control panel 用户帐户 (am-ShellExecute *SHELL "Rundll32.exe" "shell32.dll,Options_RunDLL 0") ;Open Folder Options 文件夹选项 (am-ShellExecute *SHELL "Rundll32.exe" "shell32.dll,Options_RunDLL 1") ;Open Taskbar 显示任务栏和开始菜单 (am-ShellExecute *SHELL "Rundll32.exe" "shell32.dll,Control_RunDLLAsUser") ;Open Control panel 控制面版 (am-ShellExecute *SHELL "rundll32.exe" "kernel32.dll,Sleep 10000") (am-ShellExecute *SHELL "rundll32.exe" "kernel32.dll GetVersion") (am-shellExecute *SHELL "Rundll32.exe" "user32.dll,Messagebox 0 hahah aaa 0") (am-ShellExecute *SHELL "Rundll32.exe" "shell32.dll,SHCreateLocalServerRunDll {601ac3dc-786a-4eb0-bf40-ee3521e70bfb}"); ;;Execute shell command. (am-ShellExecute *SHELL "cmd.exe") (setq root (am-namespace *SHELL "c:\\windows\\system32")) (setq exec (am-parsename root "CMD.exe")) (am-invokeverb exec) ;;Favorite,add to bookmark 加入到收藏夹 (setq mark (vlax-create-object "Shell.UIHelper.1")) (vlax-invoke mark 'AddChannel "http://www.theswamp.org/") (vlax-invoke mark 'AddFavorite "http://www.theswamp.org/" "Theswamp") (vlax-invoke mark 'AddDesktopComponent "d:\\1.jpg" "image") ;;Get information from a special path 获取某些特别路径 (defun GetInfo(*SHELL folds / objs i obj name lst prop) (setq objs (am-items (am-namespace *SHELL folds))) ;from ac-XXXXXX (setq i 0) (repeat (ap-get-count objs) (setq obj (am-item objs i)) (setq name (ap-get-name obj)) (setq prop (am-ExtendedProperty obj "type")) (setq lst (cons (cons name prop) lst)) (setq i (1+ i)) ) (reverse lst) ) ;;some examples: 一些例子用来获取某些特殊目录下的文件信息 (getInfo *SHELL ac-ssffonts) ;Get the fonts installed.获取系统中安装的字体 (getInfo *SHELL ac-ssfCONTROLS) ;Get the control panles.获取有哪些控制面板 (getInfo *SHELL ac-ssfMYPICTURES) ;Get the pictures in "My Pictures" 获取我的图片 (getInfo *SHELL ac-ssfDRIVES) ;Get the Drivers in "My computer" 获取系统的磁盘信息 (getInfo *SHELL ac-ssfnetwork) ;Get the information of "network" 获得网上邻居 (getInfo *SHELL ac-ssfsystem) ;Get the files from system folder.系统文件夹信息 (getInfo *SHELL ac-ssfRecent) ;Get the Recent opened files 获得最近打开 ;;this function to get the windows that opened by "Explore" (defun GetWindows(*SHELL / i l lst obj winobj) (vlax-invoke *SHELL 'windows) (vlax-get (vlax-invoke *SHELL 'windows) 'count) (setq winobj (vlax-invoke *SHELL 'windows)) (setq i 0) (repeat (vlax-get winobj 'count) (setq obj (vlax-invoke winobj 'item i)) (setq lst (list (vlax-get obj 'toolbar) (vlax-get obj 'StatusText) (vlax-get obj 'FullName) (vlax-get obj 'LocationURL) (vlax-get obj 'Path) ) ) (setq l (cons lst l)) (setq i (1+ i)) ) (reverse l) ) (GetWindows *SHELL) ;;最后不要忘记释放 (vlax-release-object mark) (vlax-release-object root) (vlax-release-object file) (vlax-release-object exec) (vlax-release-object *SHELL) (princ));;;=============================================================;;;Get filesystemObject ;;;=============================================================(defun c:test4 ( / FSO PATH) (setq path (strcat (getSpecialPath 1) "\\scrrun.dll")) (if (not fc-Alias) (vlax-import-type-library :tlb-filename path :methods-prefix "fm-" :properties-prefix "fp-" :constants-prefix "fc-" ) ) (setq fso (vlax-create-object "Scripting.FileSystemObject")) ;;Print a foler and its subfolders (defun showSubFolder (folder) (vlax-for subfolder (fp-get-SubFolders folder) (princ (strcat "\n" (fp-get-Path subfolder))) (ShowSubFolder subFolder) ) ) ;;Get a folder and all of its subfolders(recursively) (defun GetSubFolder (fso path / l) (defun GetSubFolder1 (folder / p) (vlax-for subfolder (fp-get-SubFolders folder) (setq p (fp-get-Path subfolder)) (setq l (cons p (GetSubFolder1 subFolder))) ) l ) (setq l (list path)) (if (fm-folderExists fso path) (reverse (getSubFolder1 (fm-getFolder fso path))) ) ) (showSubFolder (fm-GetFolder fso "C:\\temp")) (getSubFolder fso "C:\\temp") (defun GetNumOfDrives(fso / drives i) (setq drives (vlax-get fso 'drives)) (setq i 0) (vlax-for drive drives (vlax-dump-object drive) (setq i (1+ i)) ) (princ "\nThe count of disks is: ") (princ i) i ) (GetNumOfDrives fso) ;; Read stream (defun ReadStream (path format / fso file str res size) ;;path the full name of a file ;;iomode 1 ;; 1 = read, 2 = write, 8 = append ;;format 0 ;; 0 = ascii, -1 = unicode, -2 = system default (setq fso (vlax-create-object "Scripting.FileSystemObject")) (setq file (vlax-invoke fso 'getfile path)) (setq str (vlax-invoke fso 'OpenTextFile path 1 format)) (setq size (vlax-get file 'Size)) (setq res (vlax-invoke str 'read size)) (vlax-invoke str 'close) (if str (vlax-release-object str)) (if file (vlax-release-object file)) (if fso (vlax-release-object fso)) res ) ;;Write stream (defun WriteStream (path text format / fso str file res) (setq fso (vlax-create-object "Scripting.FileSystemObject")) (setq str (vlax-invoke fso 'CreateTextFile path -1 format)) (setq file (vlax-invoke fso 'getFile path)) (vlax-invoke str 'Write text) (vlax-invoke str 'close) (setq res (vlax-get file 'size)) (if str (vlax-release-object str)) (if file (vlax-release-object file)) (if fso (vlax-release-object fso)) res ) (writeStrem "C:\\test1.txt" (readStream "c:\\1.txt" -2) -2) (and fso (vlax-release-object fso)) (princ));;;=============================================================;;; Manage user account 账户管理 ;;; need run as Administrator 需要以管理员身份运行此程序 ;;; maybe invalid in window 7 or vista 在vista以上版本可能无效 ;;;=============================================================(defun c:User(/ PATH NEWUSR USROBJ) (setq path (strcat (GetSpecialPath 1) "\\shgina.dll")) (if (Not Uc-ILEU_ALPHABETICAL) (vlax-import-type-library :tlb-filename path :methods-prefix "Um-" :properties-prefix "Up-" :constants-prefix "Uc-" ) ) ;;add an account,and set password or something ;;then remove this account. (setq usrObj (vlax-create-object "Shell.users")) (setq newusr (um-create usrobj "test")) (up-put-setting newusr "AccountType" 3) (Um-changePassword newusr "111222" "") (um-remove usrObj "test") (vlax-release-object usrobj) (vlax-release-object newusr) (princ));;;=============================================================;;;Common File Dialog 公用对话框(包括文件对话框,颜色对话框等) ;;;=============================================================(defun c:FDLG(/ DLG PATH DLGOBJ FN FSOOBJ FT) (setq path (strcat (GetSpecialPath 1) "\\comdlg32.ocx")) (if (not dc-cdlalloc) (vlax-import-type-library :tlb-filename path :methods-prefix "dm-" :properties-prefix "dp-" :constants-prefix "dc-" ) ) (setq dlg (vlax-create-object "MSComDlg.CommonDialog")) ;UserAccounts.CommonDialog (dp-put-MaxFileSize dlg 10000) (dp-put-filter dlg "All Files (*.*)|*.*|Lisp Files(*.lsp)|*.lsp|DWG Files (*.dwg)|*.dwg") ;put the file filter (dm-ShowOpen dlg) (princ (strcat "\nThe file you opened is:\n" (dp-get-filename dlg))) ;;Another way (setq path (strcat (GetSpecialPath 1) "\\safrcdlg.dll")) ;safrcdlg.dll (if (not Fdp-get-FileName) (vlax-import-type-library :tlb-filename path :methods-prefix "Fdm-" :properties-prefix "Fdp-" :constants-prefix "Fdc-" ) ) ;;just for open (simple) (setq dlgobj (vlax-create-object "SAFRCFileDlg.FileOpen")) ;"SAFRCFileDlg.FileOpen" (Fdp-put-FileName dlgobj "C:\\") (Fdm-OpenFileOpenDlg dlgobj) (princ "\nThe file you opened is:\n") (princ (Fdp-get-FileName dlgobj)) (vlax-release-object dlgobj) ;;Open for save (setq dlgobj (vlax-create-object "SAFRCFileDlg.FileSave")) ;"SAFRCFileDlg.FileSave" (setq FSOobj (vlax-create-object "Scripting.FileSystemObject")) (Fdp-put-FileName dlgobj "test") (Fdp-put-fileType dlgobj ".txt") (if (Fdm-OpenFileSaveDlg dlgobj) (progn (setq FN (Fdp-get-FileName dlgobj)) (setq FT (Fdp-get-FileType dlgobj)) (princ (strcat "\nThe file you will save:\n" FN FT)) (vlax-invoke FSOobj 'CreateTextFile (strcat FN FT)) ) ) (vlax-release-object dlgobj) (vlax-release-object FSOobj) (princ));;;=============================================================;;;Get or set clipboard by Form2.0 利用form2.0来设置或获取剪切板;;;=============================================================(defun c:Form (/ BOX CTR FMO STR) (setq path (strcat (GetSpecialPath 1) "\\FM20.dll")) (if (not FMc-fmActionCopy) (vlax-import-type-library :tlb-filename path :methods-prefix "FMm-" :properties-prefix "FMp-" :constants-prefix "FMc-" ) ) ;;get text for clipboard (setq fmo (vlax-create-object "Forms.form.1")) ;Create a Form instance (setq ctr (FMP-GET-CONTROLs fmo)) ;the controls of this from (setq box (fmm-add ctr "Forms.textbox.1")) ;add a textbox control (Fmp-put-MultiLine box :vlax-true) (if (= (FMp-get-CanPaste box) :vlax-true) ;if can be pasted (progn (FMm-Paste box) ;paste into textbox (alert (fmp-get-text box)) ;show the text ) ) ;;set text for clipboard (setq str "Hello,theswamp!\nI Love you!") (Fmp-put-text box str) ;Set the text of clipboard (Fmp-put-SelStart box 0) (Fmp-put-SelLength box (Fmp-get-textlength box)) (Fmm-copy box) ;copy it into textbox ;;release object (vlax-release-object box) (vlax-release-object ctr) (vlax-release-object fmo) (princ));;;=============================================================;;;Get or set clipboard by other way 剪切板的其他方式 ;;;=============================================================(defun C:Clipboard (/ CLIP DOC IE SEL STR WORD WSH) ;; by InternetExplorer 用IE (setq IE (vlax-create-object "InternetExplorer.Application")) (vlax-invoke IE 'navigate "about:blank") (setq Clip (vlax-get (vlax-get (vlax-get ie 'Document) 'parentWindow) 'clipboardData)) (vlax-invoke clip 'setdata "text" "This is a test!") (princ (vlax-invoke clip 'GetData "text")) (vlax-release-object IE) ;;works in windows 7 用wscript (setq wsh (vlax-create-object "Wscript.Shell")) (setq str "This is a test (by wscript.shll)") (vlax-invoke wsh 'run (strcat "CMD.exe /C echo " str " | clip") 0 :vlax-false ) (vlax-release-object wsh) ;;by Microsoft office word 用office ;;Set by Word.Application (setq word (vlax-create-object "Word.Application")) (setq doc (vlax-get word 'Documents)) (setq sel (vlax-get word 'Selection)) (vlax-invoke doc 'add) (vlax-put sel 'text "This is a test(by word)") (vlax-invoke sel 'copy) (vlax-invoke word 'quit 0) (vlax-release-object word) ;;Get by Word.Application (setq word (vlax-create-object "Word.Application")) (setq doc (vlax-get word 'Documents)) (setq sel (vlax-get word 'Selection)) (vlax-invoke doc 'add) (vlax-invoke sel 'Paste) ;word.Selection.PasteAndFormat(wdFormatPlainText) (vlax-invoke sel 'wholeStory) (princ "\nThe text in clipboard is:") (princ (vlax-get sel 'text)) (vlax-release-object word));;;=============================================================;;; 获取局域网及公网地址和从网站获取信息 ;;; Get your (IP) (local IP and internet IP) ;;; An example shows how to Get your IP and get text from an URL;;;=============================================================;;;方式1(defun c:getIP() (setq ws (vlax-create-object "MSWinsock.Winsock")) ;winsock object (princ "\nYour IP is:") (princ (vlax-get ws 'LocalIP)) ;Local IP (vlax-put ws 'Protocol 0) (vlax-put ws 'RemoteHost "www.baidu.com") (vlax-put ws 'RemotePort 80) (vlax-invoke ws 'connect) ;;(vlax-invoke ws 'connect "www.yhhe.net" 80) (setq Url "http://www.baidu.com/img/baidu_logo.gif") (setq Cmd (strcat "GET " url " HTTP/1.0\r\n\r\n")) (vlax-invoke ws 'SendData cmd) (vlax-get ws 'BytesReceived) (setq data (vlax-make-variant "")) (vlax-get ws 'state) (vlax-invoke ws 'getdata data vlax-vbString) ;???此处可能行不通 (vlax-invoke ws 'close) (vlax-release-object ws) (princ));;;方式2(defun c:getIP1() (setq ws (vlax-create-object "MSWinsock.Winsock")) (princ "\n本机的地址为:") (princ (vlax-get ws 'LocalIP)) (vlax-dump-object ws T) (vlax-put ws 'Protocol 0) (vlax-put ws 'RemoteHost "www.ecranesoft.com") (vlax-put ws 'RemotePort 80) (vlax-invoke ws 'connect) ;;(vlax-invoke ws 'connect "www.yhhe.net" 80) (setq Url "http://www.ecranesoft.com/ape/book/fap/big5/pl/comx/winsock.html") (setq Cmd (strcat "GET " url " HTTP/1.0\r\n\r\n")) (vlax-invoke ws 'SendData cmd) (vlax-get ws 'BytesReceived) (setq data (vlax-make-variant vlax-vbString)) (vlax-get ws 'state) (vlax-invoke ws 'getdata data vlax-vbString) ;;??? (vlax-invoke ws 'close) (vlax-release-object ws) (princ));;;方式3(defun C:getIp2 (/ path http url web objXML file str s1 s2) (setq path (strcat (getSpecialPath 1) "\\msxml6.dll")) (if (not xc-NODE_TEXT) (vlax-import-type-library :tlb-filename path :methods-prefix "xm-" :properties-prefix "xp-" :constants-prefix "xc-" ) ) (setq http (vlax-create-object "Msxml2.XMLHTTP")) ;Microsoft.XMLHTTP or MSXML2.ServerXMLHTTP (setq url "http://iframe.ip138.com/ic.asp") ;the link of URL 链接地址 (xm-open http "GET" url :vlax-false) ;the open method 打开方式 (xm-send http) (command "delay" 2000) ;暂停两秒,等待从网站返回信息 (setq str (xp-get-responseText http)) ;get text from URL从地址中获取文本 (setq s1 (vl-string-position (ascii "[") str)) (setq s2 (vl-string-position (ascii "]") str)) (princ "\nYour IP Address is:") (princ (substr str (+ s1 2) (- s2 s1 1))) (vlax-release-object http) ;;Get text from a Link (setq web (getstring "\nPlease enter URL:")) (setq objXML (vlax-create-object "MSXML2.ServerXMLHTTP")) (xm-open objXML "GET" web :vlax-false) (xm-send objXML) (setq str (XP-GET-RESPONSETEXT objXML)) ;;(xp-get-responseXML http) ;;(xp-get-responseStream http) ;;(xp-get-responseBody http) (setq file (vl-filename-mktemp "c:\\1.html")) (setq file (open file "W")) (princ str file) (close file) (vlax-release-object objXML) (princ));;;=============================================================;;;Speak out your words. 让计算机开口说话,朗读文本之类 ;;;=============================================================(defun c:voice(/ objTTS) (setq objTTS (vlax-create-object "SAPI.SpVoice")) (vlax-invoke objTTS 'speak "Hello,Welcome to China!") (vlax-release-object objTTS) (princ));;;=============================================================;;Get the screen size of your IE window 获取屏幕分辨率 ;;;=============================================================(defun C:getscreenRes(/ IE screen) (setq IE (vlax-create-object "InternetExplorer.Application")) (vlax-invoke IE 'navigate "about:blank") (setq screen (vlax-get (vlax-get (vlax-get ie 'Document) 'parentWindow) 'screen)) (princ (vlax-get screen 'height)) (princ (vlax-get screen 'width)) (vlax-release-object IE) (princ));;;=============================================================;;; 利用ADOBE读写二进制文件 ;;;=============================================================(defun c:test (/ ARRAY BIN DAT DATA F L PATH S) ;;Read a Binary file (defun ReadBinary (FileName / stream arr) (setq stream (vlax-create-object "ADODB.Stream")) (vlax-put stream 'type 1) ;adTypeBinary (vlax-invoke stream 'open) ;adModeRead =1 adModeWrite =2 adModeReadWrite =3 (vlax-invoke stream 'LoadFromFile filename) (setq Arr (vlax-invoke-method stream 'read (vlax-get stream 'SIZE)));read stream (vlax-invoke stream 'close) (vlax-release-object stream) (vlax-safearray->list (vlax-variant-value arr)) ;if a large size file ,it will take a long time in this step ) ;;Write to a Binary file from a text stream (defun WriteBinary (FileName Array / stream) (setq stream (vlax-create-object "ADODB.Stream")) (vlax-put stream 'type 1) ;adTypeBinary (vlax-invoke stream 'open) ;adModeRead =1 adModeWrite =2 adModeReadWrite =3 (vlax-invoke-method stream 'Write array) ;write stream (vlax-invoke stream 'saveToFile fileName 2) ;save (vlax-invoke stream 'close) (vlax-release-object stream) ) (setq path (getfiled "Please select a binary file:" "c:/" "" 8 )) ;get file path (setq f (open "C:\\test.txt" "W")) (setq data (readBinary path)) (princ data f) (close F) ;;(setq stream (vl-get-resource "test")) ;we can wrap this text file into .vlx file (setq f (open "C:\\test.txt" "R")) ;open for read (setq l "") (while (setq s (read-line f)) (setq l (strcat l s)) ) (setq array (read l)) (close f) (setq dat (vlax-make-safearray 17 (cons 0 (1- (length array))))) ;17 for unsigned char (vlax-safearray-fill dat array) (setq bin (vlax-make-variant dat)) (writeBinary "C:\\test.jpg" bin) ;write binary file.);;;=============================================================;;; WIA图像控件的利用 ;;;=============================================================;| 一下是VB的源码,可以参考Sub WIA_ARGB() Dim Img 'As ImageFile Dim IP 'As ImageProcess Dim v 'As Vector Dim i 'As Long Set Img = CreateObject("WIA.ImageFile") Set IP = CreateObject("WIA.ImageProcess") Img.LoadFile r & "\1.jpg" Set v = Img.ARGBData For i = 1 To v.Count Step 300 v(i) = &HFFFF00FF 'opaque pink (A=255,R=255,G=0,B=255) Next '使用指定的位元組更新影像位元組。 IP.Filters.Add IP.FilterInfos("ARGB").FilterID Set IP.Filters(1).Properties("ARGBData") = v Set Img = IP.Apply(Img) Img.SaveFile r & "\2.jpg" UserForm1.Image1.Picture = LoadPicture(r & "\1.jpg") UserForm1.Image2.Picture = LoadPicture(r & "\2.jpg") Kill r & "\2.jpg"End Sub;;|;(defun c:img(/ path Img IPr vec cnt col old val fil i new) (setq path (strcat (getSpecialPath 1) "\\wiaaut.dll")) (if (not ic-actionEvent) (vlax-import-type-library :tlb-filename path :methods-prefix "im-" :properties-prefix "ip-" :constants-prefix "ic-" ) ) (setq Img (vlax-create-object "WIA.ImageFile")) (setq IPr (vlax-create-object "WIA.ImageProcess")) (im-loadfile Img "C:\\1.bmp") (setq vec (ip-get-ARGBData Img)) (setq cnt (ip-get-count vec)) (setq col (vlax-make-variant -2147418367)) ;-2147418368 &HFFFF00FF ;'opaque pink (A=255,R=255,G=0,B=255) (setq i 1) (repeat (/ cnt 3) (setq old (ip-get-item vec i)) (setq val (vlax-variant-value old)) (setq val (- val)) (ip-put-item vec i val) ;4294967295 (setq i (+ i 3)) ) (setq fil (ip-get-Filters IPr)) (im-add fil (ip-get-filterID (ip-get-item (ip-get-filterinfos IPr) "ARGB")) 0) (ip-put-value (ip-get-item (ip-get-Properties (ip-get-item fil 1)) "ARGBData") vec) (setq new (im-apply IPr Img)) (im-savefile new "C:\\2.bmp") (vlax-release-object Img) (vlax-release-object IPr) (vlax-release-object vec) (vlax-release-object fil) (vlax-release-object new));;;=============================================================;;; Scriptlet.TypeLib的利用 ;;;=============================================================;;;Generate a GUID(defun C:GUID (/ objSLTL str) (setq objSLTL (vlax-create-object "Scriptlet.TypeLib")) (setq str (vlax-get objSLTL 'GUID)) (vlax-release-object objSLTL) str);;;=============================================================;;; XML的利用 ;;;=============================================================(defun c:xml() (setq path (strcat (getSpecialPath 1) "\\msxml6.dll")) ;;msxml3.dll (if (not xc-NODE_TEXT) (vlax-import-type-library :tlb-filename path :methods-prefix "xm-" :properties-prefix "xp-" :constants-prefix "xc-" ) ) (setq path (strcat (getSpecialPath 1) "\\msadodc.ocx")) ;;msadox.dll (if (not dc-ad3DBevel) (vlax-import-type-library :tlb-filename path :methods-prefix "dm-" :properties-prefix "dp-" :constants-prefix "dc-" ) ) (findfile "msado15.dll") (if (not kc-adAddNew) (vlax-import-type-library :tlb-filename "C:\\Program Files\\Common Files\\System\\ado\\msado15.dll" :methods-prefix "km-" :properties-prefix "kp-" :constants-prefix "kc-" ) ))(defun c:xml() (setq wsMan (vlax-create-object "Wsman.Automation")) (setq xmlFile (vlax-create-object "MSxml.DOMDocument")) (setq session (vlax-invoke wsMan 'CreateSession)) (setq response (vlax-invoke session 'Get "http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_Service?Name=Spooler")) (vlax-invoke xmlFile 'LoadXML response) (vlax-invoke xmlfile 'save "C:/rawoutput.xml") (vlax-release-object session) (vlax-release-object xmlfile) (vlax-release-object wsMan));;;=============================================================;;; 获取外网地址--正则表达式和ServerXMLHTTP的综合运用 ;;;=============================================================(defun C:GetIP (/ htt regexp text mathes address item0) (setq Http (vlax-create-object "Msxml2.ServerXMLHTTP")) (vlax-invoke-method http 'open "GET" "http://iframe.ip138.com/ic.asp") (vlax-invoke-method http 'send) (setq text (vlax-get-property http 'responseText)) (setq RegExp (vlax-create-object "VBScript.RegExp")) (vlax-put-property RegExp 'pattern "((?:(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d))") (vlax-put-property RegExp 'IgnoreCase 1) (vlax-put-property RegExp 'Global 1) (setq matches (vlax-invoke-method RegExp 'Execute text)) (setq item0 (vlax-get-property matches 'item 0)) (setq Address (vlax-get-property item0 'value)) (vlax-release-object item0) (vlax-release-object matches) (vlax-release-object regexp) (vlax-release-object http) (alert (strcat "你的IP地址是:" address)) (princ));;;=============================================================;;; 其他控件的利用 ;;;=============================================================;;; ADO Recordset对象用于容纳一个来自数据库表的记录集。 ;;; 一个Recordset对象由记录和列(字段)组成。在 ADO 中,此对象是;;; 最重要且最常用于对数据库的数据进行操作的对象。 (defun c:kk(/ rr) (setq rs (vlax-create-object "Adodb.recordset")) (vlax-dump-object rs T) (vlax-release-object rs) (princ));;; 利用DOS控制台做些事情,譬如列举文件目录到某个文本文件,等等.(defun C:Cout(/ wsh exe) (setq wsh (vlax-create-object "WScript.shell")) (setq exe (vlax-invoke wsh 'exec "ipconfig")) (wm-run wsh "cmd.exe /C dir c:\\temp\\*.* /a /s >>c:\\1.txt") (alert (vlax-invoke (vlax-get exe 'stdout) 'readAll)) (setq exe (wm-exec wsh "cmd.exe /C dir c:\\temp\\*.* /a /s")) (princ (vlax-invoke (vlax-get exe 'stdout) 'readAll)) (vlax-release-object exe) (vlax-release-object wsh));;; 一些综合应用.(defun c:test() (setq path (strcat (GetSpecialPath 1) "\\vbscript.dll")) ;"\\Wscript.exe" (if (not RM-abs) (vlax-import-type-library :tlb-filename path :methods-prefix "Rm-" :properties-prefix "Rp-" :constants-prefix "Rc-" ) ) (setq regExp (vlax-create-object "Vbscript.RegExp")) (setq wsh (vlax-create-object "wscript.shell")) (setq scr (vlax-create-object "ScriptControl")) (vlax-put scr 'language "VBS") (vlax-make-variant 1) (vlax-create-object "vbscript.GlobalObj") (rm-abs (vlax-make-variant 1) -1) (rm-inputbox scr "Dim x As VBScript_Global.GlobalObj") (SM-EXECUTESTATEMENT scr "Function sss() Dim x As new VBScript_Global.GlobalObj end Function") (princ (readStream "C:\\delete.dcl" T)) (vlax-release-object regExp));;;FireWall等等控件均可测试。(defun FHQ() ;;(vlax-create-object "ToolsObject.TelnetTool") ;;(vlax-create-object "RCBdyCtl.Setting") (setq fwObj (vlax-create-object "HNetCfg.FwMgr")))