[求助]如何把程序加入启动组
<p>我是这样的,我有一个批处理生成和自动运行该批处理的程序,但程序需要调用自己写的程序,怎样用LISP语言把该程序自动放入“启动组”。</p> <p>;;____________________________________________________________________________________________________<br/>;; ▓ (lt:acad-rootgroup-add filname)<br/>;; [功能] 添加路径到 AutoCAD 启动组<br/>;; [参数] filname---完整路径文件名</p><p>(defun lt:acad-rootgroup-add (filname / reg-key munstar)<br/> (setq reg-key (strcat "HKEY_CURRENT_USER\\" (vlax-product-key)<br/> "<a href="file://\\Profiles\\">\\Profiles\\</a>" (getvar "cprofile")<br/> "<a href="file://\\Dialogs\\Appload\\Startup">\\Dialogs\\Appload\\Startup</a>"<br/> )<br/> munstar (vl-registry-read reg-key "NumStartup")<br/> )<br/> (if munstar<br/> (setq munstar (itoa (1+ (atoi munstar))))<br/> (setq munstar 1)<br/> )<br/> (vl-registry-write reg-key "NumStartup" munstar)<br/> (vl-registry-write reg-key (strcat munstar "Startup") filname)<br/>)</p> xshrimp 发表于 2008-3-14 13:03;;读取LoadCtrls的值,将这个值与2作“或”运算,再写回。这样可以保证AutoCAD启动时会加载Appload.arx模块 ...
大侠第二段删除程序中缺少个之程序:gps->lst-delsame,能否上传 xshrimp 发表于 2008-3-14 13:03
;;读取LoadCtrls的值,将这个值与2作“或”运算,再写回。这样可以保证AutoCAD启动时会加载Appload.arx模块 ...
老大,删除启动组缺少GPS->LST-DELSAME函数 <p>放到acad.lsp ; acad.mnl 中都应该可以的</p> 我的意思是用程序自动加入,因为我写个小程序,别人需要用又不熟悉CAD,老是叫来叫去的麻烦,有时还要楼上楼下跑,麻烦又误事,我是想让程序自动完成这一切,省去我的功夫,那位大侠指点下。先谢谢啦! <p>就像二楼说的,在acad.lsp中写一条你程序的载入语句就行了.</p> <p><strong><font face="Verdana" color="#61b713">caoyin,按照您提供的这几LISP试做了一遍,出现了这样一种情况,</font></strong></p><p><strong><font face="Verdana" color="#61b713">即有时能加载,有时又不能加载的怪事情!能否再检查或完善一下!?谢谢</font></strong></p> 这种情况我也知道,但应该不是程序问题。程序只能将相关的数据写入注册表,而无法判断CAD能否成功加载。这个在以前好像有讨论 本帖最后由 作者 于 2008-3-14 13:00:44 编辑 <br /><br /> <table class="tablebody2" width="90%" border="0" style="TABLE-LAYOUT: fixed; WORD-BREAK: break-all;"><p></p><p><tbody></tbody></p></table><table class="tablebody2" width="90%" border="0" style="TABLE-LAYOUT: fixed; WORD-BREAK: break-all;"><p><tbody></tbody></p></table><table class="tablebody2" width="90%" border="0" style="TABLE-LAYOUT: fixed; WORD-BREAK: break-all;"><p></p><p></p><p><tbody></tbody></p></table> <p>;;读取LoadCtrls的值,将这个值与2作“或”运算,再写回。这样可以保证AutoCAD启动时会加载Appload.arx模块。</p><p>;|<br/>cad appload.arx<br/>处理步骤<br/>1.读取NumStartup的值.<br/> 1.1->不存在.建立NumStartup值为0删除其他所有键值.<br/> 1.2->存在.从1Startup读取到NumStartupStartup的值.<br/> 1.2.1->监测是否存在重复.重复的删除之.不检测文件是否存在及合法.<br/> 1.2.2->其他非相关的键值全部删除.<br/>------------------------------------------------------------------------------------------------<br/>$skey "HKEY_CURRENT_USER\\Software\\Autodesk\\AutoCAD\\R16.0\\ACAD-201:804\\Profiles\\<<未命名配置>>\\Dialogs\\Appload\\Startup"<br/>$akey "HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R16.0\ACAD-201:804\Applications\AcadAppload<br/>(setq appname "se.lsp")(setq appname se.lsp)<br/>(gps->appload-filepath T)<br/>(gps->appload-filepath "se.lsp")<br/>(gps->appload-filepath AppName)<br/>1. AppName 值与nstartup值相符.<br/>2. appname T返回全部自动加载的文件列表<br/>3. appname 文件名(需包含扩展名)或全部路径名.检查自动加载文件中是否含有该文件.<br/> 有则返回该文件的全路径名或文件名<br/>|;<br/>(defun gps->appload-filepath (AppName / $skey i keyvalue numstartup svlst x)<br/> (if (member (type appname) '(STR SYM))<br/> (progn<br/> (setq $skey<br/> (strcat "HKEY_CURRENT_USER\\" (vlax-product-key) "<a href="file://\\Profiles\\">\\Profiles\\</a>"<br/> (getvar "CPROFILE") "<a href="file://\\Dialogs\\Appload\\Startup">\\Dialogs\\Appload\\Startup</a>"<br/> )<br/> )<br/> (setq NumStartup (vl-registry-read $skey "NumStartup"))<br/> (if (= (type NumStartup) 'STR)<br/> (progn<br/> (setq NumStartup (atoi NumStartup) i 1 )<br/> (repeat NumStartup<br/> (if (setq keyvalue (vl-registry-read $skey (strcat (itoa i) "Startup") ))<br/> (setq svlst (append svlst (list keyvalue)) i (1+ i) )<br/> (setq i (1+ i))<br/> )<br/> );end repeat<br/> (if svlst (setq svlst (mapcar 'strcase svlst)));end if<br/> )<br/> )<br/> (if svlst <br/> (cond ((= T appname) svlst)<br/> (T (car (member (strcase appname) svlst)))<br/> );end cond<br/> )<br/> )<br/> );end if<br/>)<br/>;|<br/>(gps->appload-deletefile "se.lsp")<br/>(gps->appload-deletefile "D:\\PROGRAM FILES\\SHLISP2006\\自编备份程序<a href="file://\\LRR\\LRR1.FAS">\\LRR\\LRR1.FAS</a>")<br/>(gps->appload-deletefile "D:\\PROGRAM FILES\\SHLISP2006\\自编备份程序<a href="file://\\LRR\\LRR2.FAS1">\\LRR\\LRR2.FAS1</a>")<br/>|;<br/>(defun gps->appload-deletefile (AppName / $skey n num svlst)<br/>(if (and (= (type appname) 'STR) (gps->appload-filepath AppName))<br/> (progn<br/> (setq <br/> $skey (strcat "HKEY_CURRENT_USER\\" (vlax-product-key) "<a href="file://\\Profiles\\">\\Profiles\\</a>" (getvar "CPROFILE") "<a href="file://\\Dialogs\\Appload\\Startup">\\Dialogs\\Appload\\Startup</a>")<br/> )<br/> (setq svlst (gps->lst-delsame (gps->appload-filepath T)) num 1)<br/> (setq svlst (vl-remove (strcase AppName) svlst)) <br/> (foreach n svlst<br/> (vl-registry-write $skey (strcat (itoa num) "Startup") n)<br/> (setq num (1+ num)) <br/> )<br/> (vl-registry-delete $skey (strcat (itoa num) "Startup"))<br/> (vl-registry-write $skey "NumStartup" (itoa (length svlst)))<br/> T<br/> )<br/>nil<br/>);end if<br/>)<br/>;;;------------------------------------------------------------------------------------------------<br/>;|<br/>(gps->appload-addfile "se.lsp")<br/>(gps->appload-addfile "D:\\PROGRAM FILES\\SHLISP2006\\自编备份程序<a href="file://\\LRR\\LRR2.FAS1">\\LRR\\LRR2.FAS1</a>")<br/>|;<br/>(defun gps->appload-addfile (AppName / $akey $skey loadctrlnum numstartup)<br/>(if (and (= (type appname) 'STR) (null (gps->appload-filepath AppName)))<br/>(progn<br/> (setq <br/> $skey (strcat "HKEY_CURRENT_USER\\" (vlax-product-key) "<a href="file://\\Profiles\\">\\Profiles\\</a>" (getvar "CPROFILE") "<a href="file://\\Dialogs\\Appload\\Startup">\\Dialogs\\Appload\\Startup</a>")<br/> $akey (strcat "HKEY_CURRENT_USER\\" (vlax-product-key) "<a href="file://\\Applications\\AcadAppload">\\Applications\\AcadAppload</a>" )<br/> )<br/> (setq NumStartup (vl-registry-read $skey "NumStartup"))<br/> (if NumStartup<br/> (progn<br/> (vl-registry-write $skey "NumStartup" (itoa (+ 1 (atoi NumStartup))))<br/> (vl-registry-write $skey (strcat (itoa (+ 1 (atoi NumStartup))) "Startup") AppName )<br/> )<br/> (progn<br/> (vl-registry-write $skey "NumStartup" "1")<br/> (vl-registry-write $skey "1Startup" AppName )<br/> )<br/> )<br/> ;;读取LoadCtrls的值,将这个值与2作“或”运算,再写回。这样可以保证AutoCAD启动时会加载Appload.arx模块。<br/> (setq loadctrlnum (vl-registry-read $akey "LOADCTRLS"))<br/> (if loadctrlnum<br/> (vl-registry-write $akey "LOADCTRLS" (Boole 7 loadctrlnum 2))<br/> (vl-registry-write $akey "LOADCTRLS" 15)<br/> ) <br/>T<br/>)<br/>nil<br/>);end if<br/>)</p> 如果把程序<u><font color="#f70909">移出</font></u>启动组可能就没那么简单了吧,请高手给个例子。