大家看看这个是否可以,这是本人编写的,里面有一些与本注册程序无关的函数,这里不再算数删除; register_lisp ; 2006.11 by emrys (defun register() (GRTEXT -2 "请输入授权码......") (setq Pass_File "C:\\Program Files\\Common Files\\Autodesk Shared\\lisp.ry") (setq fn(findfile Pass_File)) (if (= fn nil) ;创建文件 (PROGN (setq fn Pass_File) (setq fh(open fn "w")) (setq str1 "Don't remove these data!!\n") (princ str1 fh) (getcode) (princ mcode fh) (princ "\n" fh) (princ sncode fh) (close fh) (read_data fn) (pwd) ) ;END PROGN (progn (read_data fn) (if (or(= dt3 nil)(/= dt2 dt3)) (pwd) (progn (setq passflage 1) (princ"程序运行条件成熟 ,执行程序......") ) ) ) ;end progn ) ;end if (princ ) ) ;end defun ;df8888888888888888 (defun pwd () (setq dcl_id(load_dialog "dcl\\pwd.dcl")) (if (null (new_dialog "pwd" dcl_id)) (exit) ) (setq fn Pass_File) ;(read_data fn) (set_tile "mcode" dt1) (if (or(= dt3 nil)(/= dt2 dt3)) (progn (setq dt3 "你还没有注册!请输入授权号") (setq passflage 0) ) ) (set_tile "password" dt3) (action_tile "password" "(GETDATApwd)(done_dialog 3) ") (action_tile "accpet" "(done_dialog 3)") (action_tile "cancel" "(done_dialog 0)") ;(setq mc(get_tile "mcode")) ;(princ" mc=") ; (princ mc) ;(setq psd(get_tile "password" )) ;(princ " psd=") ; (princ psd) ;(saveok) ;(getdata) (setq what_next(start_dialog)) (cond ((= what_next 3)(SAVEOK)) ;((= what_next 1) (princ "\n dfg ")) ((= what_next 0) (princ "取消运行程序 ")) ) (start_dialog) (unload_dialog dcl_id) (princ) ) (defun getdatapwd() (setq mc(get_tile "mcode")) (setq psd(get_tile "password" )) ) (defun saveok() ;(setq psd(get_tile "password" )) (if (= dt2 psd) (progn (setq fn Pass_File) (setq fh(open fn "a")) (princ "\n" fh) (princ psd fh) (alert "注册成功!") (close fh) (setq passflage 1) (princ "注册成功!") ) (progn (alert "授权号不正确!请重新输入") (setq passflage 0) (pwd) ) ) ) (defun getcode() (setq sum(rnd 1 11)) (princ sum) (setq STRPWD " dfgg hewa wwhu ijut kops gper jfgr pznd vwek murj" ) (SETQ sdt1(STRLEN STRPWD)) (SETQ k(/(+ sdt1 1)5)) ;(princ sdt1) ;(princ STRPWD) (setq mcode(substr strpwd (+(* sum 5)1) 19)) (setq sncode(substr strpwd (-(*(- k sum) 5)19) 19)) (PRINC) ) ;;读取数据 (defun read_data(filename) (if (setq fp(open filename "r")) (progn (setq dt0(read-line fp)) (setq dt1(read-line fp)) (setq dt2(read-line fp)) (setq dt3(read-line fp)) (close fp) ; (setq listmcode dt1) );end progn (princ(strcat"\n failed Open file:"filename "!!!\n ")) ) ;end if ) ;;读取数束 ;生成随数 (defun rnd(n1 n2) (setq ra 66791 rb 17 nn 30) (setq imin(expt 2 31) imax(1- imin)) (if (> n1 n2) (setq n3 n1 n1 n2 n2 n3) ) (setq rn(atoi(substr(rtos(getvar "cdate")2 7)14))) (repeat nn (setq rn(+(* rn ra)rb)) (if (minusp rn)(setq rn(- rn imin))) ) ;(setq pwdstr"") (setq rn(rem rn imax)) (setq rn(/ rn imax 1.0)) (setq rn(+(fix(* rn(1+ (- n2 n1))))n1)) ) ;888888888888888888888888888 (defun psaveoldsysarg () ;保存系统变量 (setq oldcmde (getvar "cmdecho") oldblip (getvar "blipmode") oldosmo (getvar "osmode") oldclay (getvar "clayer") oldcolo (getvar "cecolor") oldltyp (getvar "celtype") oldchec (getvar "limcheck") oldrege (getvar "regenmode") oldstyl (getvar "textstyle") oldtxte (getvar "texteval") olderr *error* ) ;;在所有的程序中使用 (setq pxl_osmode (getvar "osmode")) ;; (if (tblsearch "ucs" "olducs") ;; (command "._ucs" "s" "olducs" "y") ;; (command "._ucs" "s" "olducs") ;; ) (setvar "cmdecho" 0) (setvar "blipmode" 0) (setvar "osmode" 0) (setvar "limcheck" 0) (setvar "regenmode" 1) (setvar "texteval" 1) ;;(command "handles" "on") (setq *error* pmterror) ;(pxl_undo_push) ) (defun prestoreoldsysarg () ;恢复系统变量 ;(pxl_undo_pop) (if (= (type oldcmde) 'int) (setvar "cmdecho" oldcmde)) (if (= (type oldblip) 'int) (setvar "blipmode" oldblip)) (if (= (type oldosmo) 'int) (setvar "osmode" oldosmo)) (if (= (type oldchec) 'int) (setvar "limcheck" oldchec)) (if (= (type oldrege) 'int) (setvar "regenmode" oldrege)) (if (= (type oldtxte) 'int) (setvar "texteval" oldtxte)) (if (= (type oldcolo) 'str) (setvar "cecolor" oldcolo)) (if (= (type oldclay) 'str) (setvar "clayer" oldclay)) (if (= (type oldltyp) 'str) (setvar "celtype" oldltyp)) (if (= (type oldstyl) 'str) (setvar "textstyle" oldstyl)) ;; (if (tblsearch "ucs" "olducs") (command "._ucs" "r" "olducs")) (setq *error* olderr) (menucmd"s=screen") (redraw) (princ) ) (defun pmterror(s) (princ"\n程序运行条件不足, 程序自动退出.") ;; (princ"\n错误是:") (princ s) (command ^c) ;(pxl_undo_pop) (command "._u") (prestoreoldsysarg) (setq *error* olderr) (princ) )
;DCL 文件 //ddpass.dcl pwd: dialog{ label="注册码"; :edit_box{ key="mcode"; label="注册码:"; // password_char="*"; } :edit_box{ key="password"; edit_limit=19; label="授权号:"; //password_char="*"; } ok_cancel; } ///::::: ddtoggle.dcl
|