这种贴我本来是不想回的
<p>这种贴我本来是不想回的.但看大家那么热情,还是回一下吧,看看这个.也许在某个方面能帮上你的</p><p>;;;Copyrignt chengqiang Lin 2008 for mengyang<br/>;;;为梦扬软件添加使用期限<br/>(defun my_a_date ()<br/>(setq mengyang_code_e<br/>(vl-registry-read<br/> "HKEY_CURRENT_USER\\Software\\MengYang"<br/> "my_code_date_start"<br/>)<br/>);<font color="#ff0000">读出首次安装梦扬软件的日期 </font><br/>(if (/= mengyang_code_e nil)<br/>(progn<br/>(setq mengyang_code_e<br/>(vl-registry-read<br/> "HKEY_CURRENT_USER\\Software\\MengYang"<br/> "my_code_date_start"<br/>)<br/>);<font color="#ff0000">如果已经安装梦扬则读出首次安装梦扬软件的日期</font><font color="#ff0000"><br/></font>(setq OLD_x (atof mengyang_code_e))<br/>(setq OLD (substr mengyang_code_e 3 2))<br/>(setq OLD_1 (atof OLD))<br/>(setq OLD_2 (- 30 OLD_1))<br/>(setq OLD_3 (- (+ (+ 30 OLD_x) 100) (+ OLD_1 OLD_2)));;;+<font color="#ff0000">30天试用</font><br/>(setq date_d_e (getvar "cdate"))<font color="#ff0000">;;;获取当前日期</font><br/>(setq date_d_1_e (rtos date_d_e 2 20))<br/>(setq date_d_2_e (substr date_d_1_e 5 4))<br/>(setq date_d_3_e (atof date_d_2_e))<br/>(setq my_da (- OLD_3 date_d_3_e))<br/>(if (> my_da 30.0)(setq my_da (- 30 (- 100 My_da)))(princ))<br/>(if (> my_da 30.0)(vl-registry-delete "HKEY_CURRENT_USER\\Software\\MengYang" "code")(princ))<br/><font color="#ff0000">;;剩余的使用日期</font><br/>(setq LP1 "\n-->距你使用梦扬软件的最后期限还剩")<br/>(setq LP3 "天!")<br/>(setq LP2 (rtos my_da))<br/>(setq Princ_LP (strcat LP1 LP2 LP3))<br/>(cond <br/>((<= my_da 0)(alert "\n梦扬软件已经到了使用期限,请你重新注册!")(vl-registry-delete "HKEY_CURRENT_USER\\Software\\MengYang" "code"))<br/>((<= my_da 30)(prompt Princ_LP))<br/>((> my_da 30)(alert "\n梦扬软件已经到了使用期限,请你重新注册!")(vl-registry-delete "HKEY_CURRENT_USER\\Software\\MengYang" "code"))<br/>)<br/>)<br/>(princ)<br/>)<br/>)<br/>------------------------------------------------------------------------------------</p><p>Lisp主代码(2)--主注册程序:</p><p>------------------------------------------------------------------------------------<br/>;;;梦扬软件注册模块<br/>;;;Copyrignt chengqiang Lin 2008 for mengyang<br/>(defun huanying_f ()<br/>(vl-load-com)<br/>(mc_PopupBox<br/> "请注册梦扬软件!"<br/> 0.5<br/> "提示:"<br/> 48<br/>)<br/>);;;<font color="#ff0000">首次运行提示注册</font><br/>(defun error_m ()<br/>(vl-load-com)<br/>(mc_PopupBox<br/> "注册码有误,请检查注册码,或向林承强寻求帮助!"<br/> 0.5<br/> "警告:"<br/> 48<br/>);<font color="#ff0000">注册失败提示信息</font><br/>(command "TEXTSCR");<font color="#ff0000">弹出窗口,类似按下F2</font><br/>)<br/>(defun mycopyright ();<font color="#ff0000">主函数</font><br/>(setq mengyang_code<br/>(vl-registry-read "HKEY_CURRENT_USER\\Software\\MengYang" "code")<br/>);读随机数<br/>(if (= mengyang_code nil);<font color="#ff0000">如果随机数不存在就创建随机数</font><br/> (progn<br/> (setq cpr (getvar "cputicks"))<br/> (setq cpr_1 (rtos cpr))<br/> (setq cpr_1_1 (substr cpr_1 4 8))<br/> (setq mengyang_code<br/> (vl-registry-write<br/> "HKEY_CURRENT_USER\\Software\\MengYang"<br/> "code"<br/> cpr_1_1<br/> ));<font color="#ff0000">将随机数写入到系统注册表</font><br/> )<br/> )<br/> (princ)<br/>)<br/>(setq m_code<br/>(vl-registry-read "HKEY_CURRENT_USER\\Software\\MengYang" "code")<br/>)<br/>(setq sn<br/>(vl-registry-read "HKEY_CURRENT_USER\\Software\\MengYang" "sn")<br/>)<br/>(setq cpr_right (* (/ (/ (atoi m_code) 3) 4) 7)));<font color="#ff0000">注册码算法</font><br/>(if (/= sn nil)<br/> (setq sn (atoi sn))<br/> (princ)<br/>)<br/>(if (/= sn cpr_right)<br/> (progn<br/> (huanying_f)<br/> (prompt "\n请注册梦扬软件")<br/> (setq my_meg (strcat "\n请记住你的随机数是:" m_code))<br/> (prompt my_meg)<br/> (prompt my_meg)<br/> (setq cv (load_dialog "cv.dcl"))<br/> (setq what_next 2)<br/> (while (>= what_next 2)<br/>(if (null (new_dialog "my" cv)));<font color="#ff0000">加载对话框</font><br/> (exit)<br/>)<br/>(action_tile "code_cv" "(setq code_cv $value)")<br/>(action_tile<br/> "code_cv_ps"<br/> "(setq code_cv_ps $value)(setq code_cv_ps (atoi code_cv_ps))"<br/>)<br/>(action_tile "ok" "(done_dialog 1)")<br/>(action_tile "cancel" "(done_dialog 0)")<br/>(set_tile "code_cv" m_code)<br/>(mode_tile "code_cv" 1)<br/>(setq what_next (start_dialog))<br/>(cond<br/> ((= what_next 4)<br/> (PTT_MX)<br/> (command "osnap" "mid,int,end")<br/> )<br/> ((= what_next 0)<br/> (prompt "\n用户取消了操作!\n用户取消了操作!")<br/> )<br/>)<br/> )<br/> (unload_dialog cv)<br/> (prompt my_meg)<br/> (prompt my_meg)<br/> )<br/> (princ)<br/>)<br/>(if (= code_cv_ps cpr_right));<font color="#ff0000">成功注册后将注册信息写入到注册表</font><br/> (progn<br/> (alert<br/>"\n-->非常感谢!你已成功注册梦扬软件,感谢你的使用."<br/> )<br/> (setq code_cv_ps_s (rtos code_cv_ps))<br/> (setq sn (vl-registry-write<br/> "HKEY_CURRENT_USER\\Software\\MengYang"<br/> "sn"<br/> code_cv_ps_s<br/> )<br/> )<br/> (setq sn_cn (vl-registry-write<br/> "HKEY_CURRENT_USER\\Software\\MengYang"<br/> "梦扬软件注册码"<br/> code_cv_ps_s<br/> )<br/> )<br/>(setq date_d (getvar "cdate"))<br/>(setq date_d_1 (rtos date_d 2 20))<br/>(setq date_d_2 (substr date_d_1 5 4))<br/>(setq mengyang_code(vl-registry-write "HKEY_CURRENT_USER\\Software\\MengYang" "my_code_date_start" date_d_2 ))<br/> (if (/= sn nil)<br/>(setq sn (atoi sn))<br/>(princ)<br/> )<br/> (setq sn_at (vl-registry-write<br/> "HKEY_CURRENT_USER\\Software\\MengYang"<br/> "action"<br/> "on"<br/> )<br/> )<br/> (setq sn_2 (vl-registry-write<br/> "HKEY_CURRENT_USER\\Software\\MengYang"<br/> "sn_2"<br/> "on"<br/> )<br/> )<br/> (setq code_cv_ps nil)<br/> )<br/> (princ)<br/>)<br/>(if (= sn cpr_right)<br/> (progn<br/> (prompt "\n-->你已成功注册梦扬软件,感谢使用!")<br/> (vl-registry-delete "HKEY_CURRENT_USER\\Software\\MengYang" "sn_2")<br/> (setq cpr_right nil)<br/> )<br/> (error_m)<br/>)<br/>)</p><p>------------------------------------------------------------------------------------</p><p>Lisp主代码(3)--用到的一个函数:</p><p>(defun mc_PopupBox (strText intWaitTime strTitle intDispType)<br/>(vlax-invoke-method<br/> (vlax-create-object "wscript.shell")<br/> 'Popup<br/> strText<br/> intWaitTime<br/> strTitle<br/> intDispType<br/>)<br/>)</p><p>------------------------------------------------------------------------------------</p><p>Lisp主代码(4)--对话框DCL对话框代码:</p><p> my : dialog {<br/> label = "-注册梦扬软件-梦扬软件-林承强";<br/> :column{<br/> :column{<br/> :boxed_column {<br/> label = "数据窗口";<br/> :column{<br/> : edit_box { <br/> label = "用户随机数:";<br/> key = "code_cv";<br/> width = 5;<br/> }<br/> }<br/> :column{<br/> : edit_box { <br/> label = "注册码 :";<br/> key = "code_cv_ps";<br/> width = 5;<br/>}<br/>}<br/>}<br/>}<br/>}<br/>ok_cancel;<br/> }</p><p>------------------------------------------------------------------------------------</p><p>试例:</p><p>------------------------------------------------------------------------------------<br/>;;;尺寸标准强制检测<br/>;;;Copyrignt chengqiang Lin 2008 for mengyang<br/>(defun c:j ();;;<font color="#ff0000">你定义的主程序<br/></font>(mycopyright);;;<font color="#ff0000">首先加载注册验算可以将(mycopyright)放到你的子程序这个位置,当执行J命令时程序首先执行注册验算,通过后才执行下面的代码.</font><br/>(setvar "cmdecho" 0) (setq KE 0)<br/>(setq plot_max (getvar "extmax"))<br/>(setq plot_min (getvar "extmin"))<br/>(setq plot_max_1 (car plot_max))<br/>(setq plot_max_2 (cadr plot_max))<br/>(setq plot_max (list plot_max_1 plot_max_2))<br/>(setq plot_min_1 (car plot_min))<br/>(setq plot_min_2 (cadr plot_min))<br/>(setq plot_min (list plot_min_1 plot_min_2))<br/>(setq ss (ssget "c" plot_min plot_max '((0 . "DIMENSION")))n 0)<br/>(setq date_s (getvar "cdate"))<br/>(setq date_s_1 (rtos date_s 2 20)).....................................</p> <p>哈哈..学习</p><p></p> 看不到,基本需要努力一下。 哈哈,看不见呀!!!