;;读取LoadCtrls的值,将这个值与2作“或”运算,再写回。这样可以保证AutoCAD启动时会加载Appload.arx模块。

;|

cad appload.arx

处理步骤

1.读取NumStartup的值.

1.1->不存在.建立NumStartup值为0删除其他所有键值.

1.2->存在.从1Startup读取到NumStartupStartup的值.

1.2.1->监测是否存在重复.重复的删除之.不检测文件是否存在及合法.

1.2.2->其他非相关的键值全部删除.

------------------------------------------------------------------------------------------------

$skey "HKEY_CURRENT_USER\\Software\\Autodesk\\AutoCAD\\R16.0\\ACAD-201:804\\Profiles\\<>\\Dialogs\\Appload\\Startup"

$akey "HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R16.0\ACAD-201:804\Applications\AcadAppload

(setq appname "se.lsp")(setq appname se.lsp)

(gps->appload-filepath T)

(gps->appload-filepath "se.lsp")

(gps->appload-filepath AppName)

1. AppName 值与nstartup值相符.

2. appname T返回全部自动加载的文件列表

3. appname 文件名(需包含扩展名)或全部路径名.检查自动加载文件中是否含有该文件.

有则返回该文件的全路径名或文件名

|;

(defun gps->appload-filepath    (AppName / $skey i keyvalue numstartup svlst x)

(if (member (type appname) '(STR SYM))

(progn

(setq $skey

(strcat  "HKEY_CURRENT_USER\\"   (vlax-product-key)      "\\Profiles\\"

(getvar "CPROFILE")      "\\Dialogs\\Appload\\Startup"

)

)

(setq NumStartup (vl-registry-read $skey "NumStartup"))

(if (= (type NumStartup) 'STR)

(progn

(setq NumStartup (atoi NumStartup) i 1 )

(repeat NumStartup

(if (setq keyvalue (vl-registry-read $skey (strcat (itoa i) "Startup") ))

(setq svlst (append svlst (list keyvalue))   i  (1+ i)   )

(setq i (1+ i))

)

);end repeat

(if svlst   (setq svlst (mapcar 'strcase svlst)));end if

)

)

(if svlst

(cond ((= T appname) svlst)

(T (car (member (strcase appname) svlst)))

);end cond

)

)

);end if

)

;|

(gps->appload-deletefile "se.lsp")

(gps->appload-deletefile "D:\\PROGRAM FILES\\SHLISP2006\\自编备份程序\\LRR\\LRR1.FAS")

(gps->appload-deletefile "D:\\PROGRAM FILES\\SHLISP2006\\自编备份程序\\LRR\\LRR2.FAS1")

|;

(defun gps->appload-deletefile (AppName / $skey n num svlst)

(if (and (= (type appname) 'STR)  (gps->appload-filepath AppName))

(progn

(setq

$skey (strcat "HKEY_CURRENT_USER\\" (vlax-product-key) "\\Profiles\\" (getvar "CPROFILE") "\\Dialogs\\Appload\\Startup")

)

(setq svlst (gps->lst-delsame (gps->appload-filepath T)) num 1)

(setq svlst (vl-remove (strcase AppName) svlst))

(foreach n svlst

(vl-registry-write $skey (strcat (itoa num) "Startup") n)

(setq num (1+ num))

)

(vl-registry-delete $skey (strcat (itoa num) "Startup"))

(vl-registry-write $skey "NumStartup" (itoa (length svlst)))

T

)

nil

);end if

)

;;;------------------------------------------------------------------------------------------------

;|

(gps->appload-addfile "se.lsp")

(gps->appload-addfile "D:\\PROGRAM FILES\\SHLISP2006\\自编备份程序\\LRR\\LRR2.FAS1")

|;

(defun gps->appload-addfile (AppName / $akey $skey loadctrlnum numstartup)

(if (and (= (type appname) 'STR) (null (gps->appload-filepath AppName)))

(progn

(setq

$skey (strcat "HKEY_CURRENT_USER\\" (vlax-product-key) "\\Profiles\\" (getvar "CPROFILE") "\\Dialogs\\Appload\\Startup")

$akey (strcat "HKEY_CURRENT_USER\\" (vlax-product-key) "\\Applications\\AcadAppload" )

)

(setq NumStartup (vl-registry-read $skey "NumStartup"))

(if NumStartup

(progn

(vl-registry-write $skey "NumStartup" (itoa (+ 1 (atoi NumStartup))))

(vl-registry-write $skey (strcat (itoa (+ 1 (atoi NumStartup))) "Startup") AppName )

)

(progn

(vl-registry-write $skey "NumStartup" "1")

(vl-registry-write $skey "1Startup" AppName )

)

)

;;读取LoadCtrls的值,将这个值与2作“或”运算,再写回。这样可以保证AutoCAD启动时会加载Appload.arx模块。

(setq loadctrlnum (vl-registry-read $akey "LOADCTRLS"))

(if loadctrlnum

(vl-registry-write $akey "LOADCTRLS" (Boole 7 loadctrlnum 2))

(vl-registry-write $akey "LOADCTRLS" 15)

)

T

)

nil

);end if

)

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐