3 实现过程
3.1新建一个表单
在这个表单的INIT事件中写入如下代码来定义注册表API函数所用到的常量和引入注册表API函数:
PUBL HCROOT,DEFINE HCUSER,DEFINE HLMACHINE,HKEY_USERS,ERRORXX
HCROOT=-2147483648
HCUSER=-2147483647
HLMACHINE=-2147483646
HKEY_USERS=-2147483645
ERRORXX=0
DECLARE INTEGER RegOpenKey IN WIN32API INTEGER NHKEY,STRING CSUBKEY,INTEGER @NHANDLE
DECLARE INTEGER RegCreateKey IN Win32API INTEGER NHKEY,STRING CSUBKEY,INTEGER @NHANDLE
DECLARE INTEGER RegCloseKey IN WIN32API INTEGER NHKEY
DECLARE INTEGER RegDeleteKey IN WIN32API INEGER NHKEY,STRING CSUBKEY
DECLARE INTEGER RegDeleteValue IN WIN32API INTEGER NHKEY,STRING CENTRY
usetime=thisform.myreadregistrystring(HLMACHINE,"SOFTWARE\testtime","thistime")
IF ISNULL(usetime)
=THISFORM.MYREGCREATEKEY(HLMACHINE,"SOFTWARE\testtime",0)
=THISFORM.mywriteregistrystring(HLMACHINE,"SOFTWARE\testtime","thistime","30")
messagebox("注意:你可以免费使用30次本系统,请及时注册购买正版软件","提示窗口")
ELSE
IF Val(usetime)=1
messagebox("使用次数已到,请购买正版软件","提示窗口")
ELSE
|