本帖最后由 tryhi 于 2016-3-22 12:34 编辑
在论坛一直搜索不到一个现成的加入启动组的函数,写了一个跟大家分享
- (vl-Load-COM)
- (defun try-tuo-path(/ path str)
- (princ "\n")
- (setq path (getvar "lastprompt"))
- (if (wcmatch (strcase path) "*(LOAD "*")
- (setq str (vl-string-search "(LOAD "" path)
- path (substr path (+ str 8) (- (vl-string-search "")" path) str 7))
- )
- )
- (vl-string-translate "/" "\" path)
- )
- (defun try-appload-startup (path / i k n new-n strart-path)
- (setq n
- (vl-registry-read
- (setq strart-path
- (strcat "HKEY_CURRENT_USER\"
- (vlax-product-key)
- "\\Profiles\"
- (getvar "CPROFILE")
- "\\Dialogs\\Appload\\Startup"
- ))
- "NumStartup"
- )
- i 0
- k T
- )
- (repeat (atoi n)
- (setq i(1+ i))
- (if(= path(vl-registry-read strart-path (strcat(itoa i)"Startup")))(setq k nil))
- )
- (if k
- (progn
- (vl-registry-write strart-path "NumStartup" (setq new-n(itoa (1+ (atoi n)))))
- (vl-registry-write strart-path (strcat new-n "Startup") path)
- )
- )
- )
- ;;;程序开始
- (setq path(try-tuo-path))
- (if (= ":"(substr path 2 1))(progn(try-appload-startup path)(prompt "\n成功加载至启动组"))(prompt "\n本程序只能通过拖动来加载"))
- (prin1)
注:附件的内容跟帖子里面的源码是一样的,不过多了几句无关紧要的注释,附件只是方便大家下载
|