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