linshiyin2 发表于 2010-8-28 10:30:00

[原创]注册程序

高手给改一下,老是出现("00:0C:29:29:8E:72") ; 错误: 参数类型错误: stringp nil

;;;初学liSP编程,编了一个lisp程序注册功能的模块,里边好多的语句都是明经网友的,深表感谢
;;;现将源程序拿出来共享。程序编的可能罗唆一些,望老鸟不要见笑,恳请指点。
;;;
;;;在C:\langjs目录下存储一个key.txt文件
;;;将对话框文件zhuc.dcl拷贝到AUTOCAD搜索支持的目录
;;;在你想要保护的lisp程序插入一句:
;;;(jiany)
;;;加载并运行程序。
;;;
;;;当想要保护的程序执行到(jiany)时
;;;程序打开C:\langjs\key.txt并取得里边存储的授权码,
;;;检验其和硬盘序列号之间的算法关系是否成立,(我的程序中只是简单的判断相等,可以改复杂一些)
;;;如果正确,则继续执行lisp程序
;;;如不成立
;;;则弹出注册对话框,输入正确的授权码,才能继续执行lisp程序,如授权码不正确,则退出。
;;;同时将正确的授权码存储在C:\langjs\key.txt中,以便下次进行检验
;;;
;;;如果想要改变key.txt存储路径和算法请自己在程序中修改。
;;;
;;;
;;;检验授权码程序
(defun c:jiany()
   (setq f (open "C:\\key.txt""r"))
   (setq fee2 (read-line f));;读取key为fee2
   (close f)
   (getmcid);;;获取物理序列号
(if (/= fee1 fee2)   ;;;这里是检验算法
(zhuc)
(prin1)
)
)
;;;对话框驱动程序
(defun zhuc()
(setq dcl_id (load_dialog "custom.dcl"))
   (new_dialog "zhuc" dcl_id)
   (getmcid)
   (set_tile "c01"fee1)
   (action_tile "c03" "(gsouqm) (done_dialog 1)")
   (setq bb (start_dialog))
   (cond ((= bb 1)(wsouqm ))
         (t (exit))
   )
(prin1)
)
(defun gsouqm();;;获取授权密码
   (setq ppp(get_tile "c02"))
   (prin1)
)
(defun wsouqm ();;;写入授权密码
   (setq f (open "C:\\key.txt" "w"))   
   (write-line ppp f)
   (close f)
;;;   (jiany)
   (prin1)
)
;;;获得硬盘虚拟序列号程序
;;获取网卡号cpu序列号
;;Test OK with XP
;;Use WMI to Get Networkadapter MAC.
;;Author : eachy
;;Web : http://www.xdcad.net
;;2005.11.22
(defun getmcid (/ mac WMIobj serv lox sn)
(vl-load-com)
;;;以下读取mac地址
(setq mac '())
(if (SETQ WMIobj (VLAX-CREATE-OBJECT "wbemScripting.SwbemLocator"))
    (progn (SETQ serv (VLAX-INVOKE WMIobj 'ConnectServer "." "\\root\\cimv2" "" "" "" "" 128 nil))
         (setq lox (vlax-invoke serv 'ExecQuery "Select * From Win32_NetworkAdapter "))
         (vlax-for item lox
             (if (and (= (vlax-get item 'NetConnectionID) "本地连接") ;中文系统
                      (not (member (setq sn (vlax-get item 'MACAddress)) mac))
               )
               (setq mac (cons sn mac))
             )
         )
    )
)
;;;(setq macid mac)
(print mac)
;;;(setq fee1 mac )
(princ)
)
;;;-----------------------------------
;;;取出串中字母数字 明经 ZZXXQQ 2008.9.15
;;;-----------------------------------
(defun qzmsz (txt)
;;;   (setq txt "1a2b3))::"
;;;         i 1
;;;         j 1
;;;ntxt "")
   (repeat (strlen txt);;;对txt进行其长度次数的循环计算
    (setq tx (substr txt j 1)) ;;;取出第j个字符
    (if (or (<= "a" (strcase tx T) "z") (<= "0" tx "9")) ;;;将其转换为大写字母判断是否为A-Z之间或者0-9
   (setq ntxt (strcat ntxt tx)) ;;;不是的话将其追加到ntxt
    )
    (setq j (1+ j))
   )
   (print ntxt)
(princ)
)







//
//注册对话框
//
zhuc:dialog{
label="注册信息";
spacer_1;
:text {label="                软件注册";}
:edit_box{label="机器码";key="c01";edit_width=30;}
:edit_box{label="授权码";key="c02";edit_width=30;}

spacer_1;
:row{
:text {label="       ";}
:button {label="注册";key="c03";
width=12;
fixed_width=true;
}
cancel_button;
:text {label="";}
}
}

waterchen 发表于 2010-12-7 18:27:43

正想學這方面的,謝謝你的分享!

Gu_xl 发表于 2010-12-7 19:25:58

("00:0C:29:29:8E:72") 是表,程序要的是string,类型不符!可将表("00:0C:29:29:8E:72")字串取出使用!(car ("00:0C:29:29:8E:72"))

another2121 发表于 2010-12-7 22:03:05

85.;;;-----------------------------------
86.;;;取出串中字母数字 明经 ZZXXQQ 2008.9.15
87.;;;-----------------------------------
这一段代码是精典。。。。。

hhh454 发表于 2010-12-8 09:26:46

请高手完成上面代码,在此感谢,

zxjing 发表于 2011-1-1 12:00:37

本帖最后由 zxjing 于 2011-1-1 12:01 编辑

another2121 发表于 2010-12-7 22:03 http://bbs.mjtd.com/static/image/common/back.gif
85.;;;-----------------------------------
86.;;;取出串中字母数字 明经 ZZXXQQ 2008.9.15
87.;;;----- ...

非常经典,我的好些程序中也都保留了跟这个类似的一句哈哈,感谢热心的Z版!
顺便祝大家新年快乐!

yxl88168 发表于 2011-4-28 19:10:19

谢谢楼主,学习了

zhengchuan 发表于 2011-4-29 01:00:23

谢谢楼主,学习了

jxphklibin 发表于 2011-6-16 15:08:37

修改程序是最麻烦最吃力的事情,调试需要很多时间的

haiyunzhou 发表于 2011-12-31 15:49:12

楼主写的不错了 继续学习
页: [1] 2
查看完整版本: [原创]注册程序