usetime=allt(str(val(usetime)-1))
messagebox("注意:你还有"+usetime+"次可以使用本系统,请及时注册购买正版软件","提示窗口")
=THISFORM.mywriteregistrystring(HLMACHINE,"SOFTWARE\testtime","thistime",usetime)
ENDIF
ENDIF
3.2为表单添加方法MyRegCreateKey
封装RegCreateKey函数,代码如下:
LPARAMETERS HKEY,SUBKEY,NHANDLE
LOCAL BS
BS=RegCreateKey(HKEY,SUBKEY,@NHANDLE)
=RegCloseKey(nhandle)
IF BS#ERRORXX
RETURN .NULL.
ENDIF
RETURN .T.
3.3为表单添加方法MyWriteRegistryString
用于写入键值,程序代码如下:
LPARAMETERS HKEY,SUBKEY,ENTRY,VALUE
LOCAL NHANDLE,BS,NSIZE,CDAABUFFER,NTYPE
NHANDLE=0
BS=RegOpenKey(HKey,subkey,@nhandle)
if bs#ERRORXX
return .null.
endif
DECLARE INTEGER RegSetValueEx IN Win32API INTEGER NHKEY,STRING LPSZENTRY,;
INTEGER DWRESERVED,INTEGER FDWTYPE,STRING LPBDATA,INTEGER CBDATA
NSIZE=LEN(VALUE)
BS=RegSetValueEx(nhandle,entry,0,1,value,nsize)
=RegCloseKey(nHandle)
if bs#ERRORXX
return .null.
endif
|