hao3ren
发表于 2012-7-19 19:51:29
(defun c:tt ()
(setq zhukey (vl-registry-read "HKEY_CURRENT_USER\\Software\\TOOLS" "SN"))
(if (/= zhukey "1111")
(progn
(setq zhusn 2222)
(alert "申请码为:2222")
(setq zhukey (itoa (/ zhusn 2)))
(setq zhuce (itoa (getint "\n请输入注册码:")))
(if (/= zhukey zhuce)
(progn
(alert "请输入正确的注册码")
(exit)
)
(progn
(vl-registry-write "HKEY_CURRENT_USER\\Software\\TOOLS" "SN" zhuce)
)
)
)
)
(setvar "CMDECHO" 0)
(command "line")
(setvar "CMDECHO" 1)
(princ)
)
461045462
发表于 2012-7-19 21:30:12
谢谢各位高手
来学习学习。
谢谢!
qcw911
发表于 2012-7-20 08:10:43
LISP源代码:
------------------------------------------------------------------------------------
;;;梦扬软件独立注册模块改进优化版
;;;Copyrignt chengqiang Lin 2009 for mengyang(作者:林承强)
(defun CODE_Str ()
(defun mc_PopupBox (strText intWaitTime strTitle intDispType)
(vlax-invoke-method
(vlax-create-object "wscript.shell")
'Popup
strText
intWaitTime
strTitle
intDispType
)
)
(defun End_Off_Ri ()
(vl-load-com)
(mc_PopupBox
"梦扬软件CAD工具集需获得授权方可正常使用,点击确定输入授权码!"
0.5
"提示:"
48
)
(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 Snt $value)"
)
(action_tile "ok" "(done_dialog 1)")
(action_tile "cancel" "(done_dialog 0)")
(set_tile "code_cv" code_suiji)
(mode_tile "code_cv_ps" 2)
(mode_tile "code_cv_ps" 3)
(mode_tile "code_cv" 1)
(setq what_next (start_dialog))
(cond
((= what_next 1)
(prompt "\n用户取消了操作!\n用户取消了操作!")
)
((= what_next 0)
(prompt "\n用户取消了操作!\n用户取消了操作!")
)
)
(unload_dialog cv)
)
)
(setvar "cmdecho" 0)
(setq CODE_Str_path_file (strcat "c:\\windows\\system32\\" "MYS.dll"))
(setq code_suiji_1 (open CODE_Str_path_file "r"))
(if (/= code_suiji_1 nil)
(progn
(setq CODE_read (read-line code_suiji_1))
(close code_suiji_1)
)
(princ)
)
(if (or (= code_suiji_1 nil) (= CODE_read nil) (= CODE_read ""))
(progn
(setq CODE_Cputicks_1 (substr (rtos (getvar "cputicks")) 4 8))
(setq TT_path_file (strcat "c:\\windows\\system32\\" "MYS.dll"))
(setq code_suiji_1 (open TT_path_file "w"))
(setq code_suiji (write-line CODE_Cputicks_1 code_suiji_1))
(setq snt (write-line "0" code_suiji_1))
(close code_suiji_1)
(setq Date (getvar "cdate"))
(setq Nian (substr (rtos Date 2 20) 1 4)
Yue (substr (rtos Date 2 20) 5 2)
Ri (substr (rtos Date 2 20) 7 2)
Time_Start (strcat nian yue ri)
)
(setq CODE_Str_path_file
(strcat "c:\\windows\\system32\\"
"MYS.dll"
)
)
(setq code_suiji_x (open CODE_Str_path_file "a"))
(setq Time_Start_reg (write-line Time_Start code_suiji_x))
(setq time_end_ri (rtos (- (+ (atof ri) 180) 30)))
(setq time_end_yue Yue)
(if (> (+ (atof ri) 30) 30)
(setq time_end_yue (rtos (+ (atof Yue) 1)))
(princ)
)
(if (< (atof time_end_ri) 10)
(setq time_end_ri (strcat "0" time_end_ri))
(princ)
)
(if (>= (atof time_end_yue) 13)
(progn (setq time_end_yue "1")
(setq Nian (rtos (+ (atof Nian) 1)))
)
(princ)
)
(if (< (atof time_end_yue) 10)
(setq time_end_yue (strcat "0" time_end_yue))
(princ)
)
(setq Time_end (strcat nian time_end_yue time_end_ri))
(setq Time_end_reg (write-line Time_end code_suiji_x))
(close code_suiji_x)
)
(progn
(setq CODE_Str_path_file
(strcat "c:\\windows\\system32\\" "MYS.dll")
)
(setq code_suiji_1 (open CODE_Str_path_file "r"))
(setq code_suiji (read-line code_suiji_1))
(close code_suiji_1)
(setq code_suiji_x (open CODE_Str_path_file "r"))
(repeat 2
(setq snt (read-line code_suiji_x))
)
(close code_suiji_x)
(setq code_suiji_y (open CODE_Str_path_file "r"))
(repeat 3
(setq Time_Start (read-line code_suiji_y))
)
(close code_suiji_y)
(setq code_suiji_z (open CODE_Str_path_file "r"))
(repeat 4
(setq Time_end (read-line code_suiji_z))
)
(close code_suiji_z)
)
)
(setq CODE_Right (* (/ (/ (atoi code_suiji) 5) 5) 5))
(if (/= (atof Snt) CODE_Right)
(progn
(End_Off_Ri)
(setq END_Msg_suiji (strcat "\n请记住你的随机数是:" code_suiji))
(princ END_Msg_suiji)
(if (/= (atof Snt) CODE_Right)
(progn
(alert
"\n你输入的授权码不正确,但你可继续使用梦扬软件的功能,点击确定继续!"
)
)
(progn
(alert "\n授权码正确!请继续工作.......!")
(setq TT_path_file
(strcat "c:\\windows\\system32\\" "MYS.dll")
)
(setq code_suiji_2 (open TT_path_file "w"))
(setq code_suiji (write-line code_suiji code_suiji_2))
(setq snt (write-line snt code_suiji_2))
(setq Time_Start_reg (write-line Time_Start code_suiji_2))
(setq Time_end_reg (write-line Time_end code_suiji_2))
(close code_suiji_2)
)
)
)
(princ)
)
(setq CODE_Str_path_file (strcat "c:\\windows\\system32\\" "MYS.dll"))
(setq code_suiji_x (open CODE_Str_path_file "r"))
(repeat 3
(setq Time_Start_reg (read-line code_suiji_x))
)
(close code_suiji_x)
(setq CODE_Str_path_file (strcat "c:\\windows\\system32\\" "MYS.dll"))
(setq code_suiji_x (open CODE_Str_path_file "r"))
(repeat 4
(setq Time_end_reg (read-line code_suiji_x))
)
(close code_suiji_x)
(setq Date_now (getvar "cdate"))
(setq Nian_now (substr (rtos Date_now 2 20) 1 4)
Yue_now (substr (rtos Date_now 2 20) 5 2)
Ri_now (substr (rtos Date_now 2 20) 7 2)
Time_Start_now (atof (strcat nian_now yue_now ri_now))
)
(if (or (> Time_Start_now (atof Time_end_reg))
(< Time_Start_now (atof Time_Start_reg))
)
(progn
(vl-file-delete "c:/windows/system32/MYS.dll")
)
(princ)
)
)
------------------------------------------------------------------------------------
DCL对话框源代码(请将对话框代码存为CV.DCL文件)
my : dialog {
label = "-注册梦扬软件-梦扬软件-林承强";
:column{
:column{
:boxed_column {
label = "数据窗口";
:column{
: edit_box {
label = "用户随机数:";
key = "code_cv";
width = 5;
}
}
:column{
: edit_box {
label = "授权码 :";
password_char="*";
key = "code_cv_ps";
width = 5;
}
}
}
}
}
ok_cancel;
}
------------------------------------------------------------------------------------
程序用法:
仅需在你的程序前面加上(CODE_Str)即可,另需要将上面lisp源代码复制到你程序里面,范例:
(defun c:XX () ;;;XX是你定义的命令
(CODE_Str)
.............;;;;省略指你的源代码
)
;;;end
程序解释:
生成一个名为MY.DLL的文件,此文件记录了用户初始的随机数首次安装的日期等信息,然后每次执行程序时,程序会将用户输入的注册码和随机数进行对比并判断注册码是否正确,如果不正确则给予提示,如果正确则将正确的注册码及注册时间写入到MY.DLL文件中,并再下次运行程序时不再提示。此版本的注册模块梦扬特增加了30天时间限制功能,用户成功注册后程序将记录随机数 注册码 安装日期 限制日期等信息,当程序检测到系统时间达到限制时间时则重新生成新的随机数并提示注册。
357785513
发表于 2012-7-20 09:27:19
23楼代码有好些没看懂,另做法有点涵糊
建议做一个GIF文件
hao3ren
发表于 2012-7-20 09:45:51
(defun c:tt ()
(setq zhukey (vl-registry-read "HKEY_CURRENT_USER\\Software\\TOOLS" "SN"))
(if (/= zhukey "1111")
(progn
(setq zhusn 100)
(alert "申请码为:100")
(setq zhukey (itoa (- (+ (/ zhusn 2) 3) 5)))
(setq zhuce (itoa (getint "\n请输入注册码:")))
(if (/= zhukey zhuce)
(progn
(alert "请输入正确的注册码")
(exit)
)
(progn
(vl-registry-write "HKEY_CURRENT_USER\\Software\\TOOLS" "SN" zhuce)
)
)
)
)
(setvar "CMDECHO" 0)
(command "line")
(setvar "CMDECHO" 1)
(princ)
)
(setq zhukey (itoa (- (+ (/ zhusn 2) 3) 5)))这句是根据申请吗算注册码的,简单的运算
这玩意建议看看就行,是在我没多大用处,不要在这里浪费了
hhh454
发表于 2012-7-20 20:10:19
hao3ren 发表于 2012-7-19 19:51 static/image/common/back.gif
(defun c:tt ()
(setq zhukey (vl-registry-read "HKEY_CURRENT_USER\\Software\\TOOLS" "SN"))
(if (/ ...
谢谢大师的帮助,学习了。
hhh454
发表于 2012-7-20 20:11:53
qcw911 发表于 2012-7-20 08:10 static/image/common/back.gif
LISP源代码:
------------------------------------------------------------------------------------ ...
谢谢您的帮助,感谢
zml84
发表于 2012-7-20 22:27:33
本帖最后由 zml84 于 2012-7-20 22:28 编辑
建议先把程序功能写利索了,再考虑注册的事。别本末倒置。
hhh454
发表于 2012-7-21 11:32:02
zml84 发表于 2012-7-20 22:27 static/image/common/back.gif
建议先把程序功能写利索了,再考虑注册的事。别本末倒置。
谢谢你的指导,这个帖子的主题就是学习"if"的使用,以前一直不会用,学习中
hao3ren
发表于 2012-7-22 11:22:18
429014673按下命令后没有提示注册,直接画直线了………………发表于 前天 21:53
你把你的注册表收拾一下就行了