pb10中怎样实现时间限制(或倒计时)?

Bull_Lee 2009-05-16 12:42:41
加精
如题,部分源代码如下,但是文件句柄取不到,谁能帮我改改?
open事件中:
ulong l_handle,lu_class
string ls_name
Long i,ll_days,ll_installdateno,ll_days_count_down,ll_days_diff
Blob lbb_installdate[2]
String ls_installdate[2]
Date ldate_installdate[2],ldate_lastacctime,ldate_systime
systemtime lstr_creationtime,lstr_lastaccesstime,lstr_lastwritetime,lstr_systemtime

ls_name='程序'
l_handle=FindWindowA(lu_class,ls_name)
IF l_handle>0 THEN
MessageBox('提示信息','应用程序'+ This.AppName +'已经运行,不能多次启动!')
Halt Close
END IF

//检查软件最近一次运行的时间
l_handle=CreateFile("C:\Windows\system32\nsuser.dat",1,1,0,3,0,0)
GetFileTime(l_handle,lstr_creationtime,lstr_lastaccesstime,lstr_lastwritetime) //取得文件信息
FileTimeToSystemTime(lstr_lastaccesstime,lstr_systemtime) //文件时间转换为系统时间
ldate_lastacctime=date(string(lstr_systemtime.year)+'-'+string(lstr_systemtime.month)+'-'+string(lstr_systemtime.day)) //最后访问时间
GetSystemTime(lstr_systemtime) //取系统时间
ldate_systime=date(string(lstr_systemtime.year)+'-'+string(lstr_systemtime.month)+'-'+string(lstr_systemtime.day)) //系统时间
if ldate_lastacctime>ldate_systime then
Messagebox('机器时间','机器时间已经改变,你不能改变机器时间!',Exclamation!,OK!)
Halt Close
end if
//时间限制,倒计时
ll_days_count_down=30 //倒计时天数,如果为0不使用倒计时
//设置安装时间
RegistryGet("HKEY_LOCAL_MACHINE\SOFTWARE\Modify","Instlltime",RegBinary!,lbb_installdate[1]) //读取安装时间1
RegistrySet("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion","Modify",RegString!,"") //建立主键
RegistryGet("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Modify","Installtime",RegBinary!,lbb_installdate[2]) //读取安装时间2
ls_installdate[1]=string(lbb_installdate[1])
ls_installdate[2]=string(lbb_installdate[2])
if ls_installdate[1]<>'' and ls_installdate[2]<>'' then
for i=1 to 2
ldate_installdate[i]=date(ls_installdate[i])
next
ll_days=DaysAfter(ldate_installdate[1],ldate_installdate[2])
if ll_days>0 then
RegistrySet("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Modify","Installtime",RegBinary!,lbb_installdate[1]) //写入安装时间1
elseif ll_days<0 then
RegistrySet("HKEY_LOCAL_MACHINE\SOFTWARE\Modify","Installtime",RegBinary!,lbb_installdate[2]) //写入安装时间2
end if
if ll_days_count_down<>0 then
if ll_days>0 then
ll_days_diff=DaysAfter(ldate_installdate[1],ldate_systime)
elseif ll_days<0 then
ll_days_diff=DaysAfter(ldate_installdate[2],ldate_systime)
end if
if ll_days_diff>ll_days_count_down then
Messagebox('倒计时','倒计时'+string(ll_days_count_down)+'天完毕,系统停止运行!',Exclamation!,OK!)
Halt Close
end if
end if
else
if ls_installdate[1]='' then ll_installdateno=1
if ls_installdate[2]='' then ll_installdateno=2
if ls_installdate[1]='' and ls_installdate[2]='' then ll_installdateno=3
GetFileTime(l_handle,lstr_creationtime,lstr_lastaccesstime,lstr_lastwritetime) //取得文件信息
FileTimeToSystemTime(lstr_creationtime,lstr_systemtime) //文件时间转换为系统时间
ls_installdate[1]=string(lstr_systemtime.year)+'-'+string(lstr_systemtime.month)+'-'+string(lstr_systemtime.day) //安装时间1
ls_installdate[2]=ls_installdate[1] //安装时间2
for i=1 to 2
lbb_installdate[i]=blob(ls_installdate[i])
next
if ll_installdateno=1 or ll_installdateno=3 then
RegistrySet("HKEY_LOCAL_MACHINE\SOFTWARE\Modify","Installtime",RegBinary!,lbb_installdate[1]) //写入安装时间1
end if
if ll_installdateno=2 or ll_installdateno=3 then
RegistrySet("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Modify","Installtime",RegBinary!,lbb_installdate[2]) //写入安装时间2
end if
end if

//给系统日期赋值
gdate_sysdate=2009-05-31
RegistryGet("HKEY_LOCAL_MACHINE\SOFTWARE\Modify","Password",RegString!,gs_pwd) //登录密码
//RegistryGet("HKEY_LOCAL_MACHINE\SOFTWARE\Modify","SchoolNo",RegString!,ls_school_no) //ID号
ls_school_no="64526586"
IF Today()>gdate_sysdate THEN
MessageBox('日期过期','当前的日期已经超过'+string(gdate_sysdate),Exclamation!,OK!)
Halt Close
END IF
...全文
1005 19 打赏 收藏 转发到动态 举报
写回复
用AI写文章
19 条回复
切换为时间正序
请发表友善的回复…
发表回复
WorldMobile 2009-05-24
  • 打赏
  • 举报
回复
友情提示,如果问题解决,请楼主尽快结贴,本贴已经移至精华区,希望楼主再接再励
lovemoreh 2009-05-24
  • 打赏
  • 举报
回复
如果PB程序员不了解纯PB代码是没有任何秘密可言的这一点,对PB程序员是非常危险的。

用纯PB代码给PB程序加密,与没有加密是完全一样的。
Bull_Lee 2009-05-23
  • 打赏
  • 举报
回复
下面将我研究的如何实现时间限制(倒计时,防止别人修改机器时间,以及过期时间)的方法公开如下:

在应用对象的Instance变量声明如下:
uo_file_function uo_1 //声明读写文件时间的对象
DateTime creationtime,lastaccesstime,lastwritetime //文件创建时间,最近访问时间,最后修改时间

定义一个全局systemtime结构:
unsignedinteger year
unsignedinteger month
unsignedinteger dayofweek
unsignedinteger day
unsignedinteger hour
unsignedinteger minute
unsignedinteger second
unsignedinteger millisecond

全局外部函数声明如下:
SUBROUTINE GetLocalTime(ref systemtime systimerptr) Library "kernel32.dll"

在open事件中代码如下:
string ls_pathname
Long i,j,ll_days,ll_installdateno,ll_days_count_down,ll_days_diff,ll_pos[2]
Blob lbb_installdate[2],lbb_recentdate
String ls_installdate[2]
Date ldate_installdate[2],ldate_recentdate,ldate_systime,ldate_sysdate
systemtime lstr_systemtime

//读取文件时间
ls_pathname=GetCurrentDirectory() + "\test.exe"
if Not FileExists(ls_pathname) then //检查test.exe是否存在
Messagebox('提示','你不能更改test.exe的文件名!',Exclamation!,OK!)
Halt
end if
uo_1.of_file_get_times( ls_pathname, creationtime, lastaccesstime, lastwritetime) //读取文件时间

//检查软件最近一次运行的时间
RegistrySet("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion","Modify",RegString!,"") //建立主键Modify
RegistryGet("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Modify","recenttime",RegBinary!,lbb_recentdate) //读取最近一次运行的时间
if string(lbb_recentdate)<>'' then ldate_recentdate=date(f_decrypt(string(lbb_recentdate),0419)) //解密字符串
GetLocalTime(lstr_systemtime) //取本地系统时间
ldate_systime=date(string(lstr_systemtime.year)+'-'+string(lstr_systemtime.month)+'-'+string(lstr_systemtime.day)) //本地系统时间
if ldate_recentdate>ldate_systime then
Messagebox('错误','系统错误,你无权使用本系统!',Exclamation!,OK!)
Halt Close
end if

//时间限制,倒计时
ll_days_count_down=0 //倒计时天数,如果为0不使用倒计时
//设置安装时间
RegistrySet("HKEY_LOCAL_MACHINE\SOFTWARE","Modify",RegString!,"") //建立主键Modify
RegistryGet("HKEY_LOCAL_MACHINE\SOFTWARE\Modify","Installtime",RegBinary!,lbb_installdate[1]) //读取安装时间1
RegistryGet("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Modify","Installtime",RegBinary!,lbb_installdate[2]) //读取安装时间2
ls_installdate[1]=string(lbb_installdate[1])
ls_installdate[2]=string(lbb_installdate[2])
for i=1 to 2
if ls_installdate[i]<>'' then ls_installdate[i]=f_decrypt(ls_installdate[i],0419) //解密字符串
next
if ls_installdate[1]<>'' and ls_installdate[2]<>'' then
for i=1 to 2
ldate_installdate[i]=date(ls_installdate[i])
next
ll_days=DaysAfter(ldate_installdate[1],ldate_installdate[2])
if ll_days>0 then
RegistrySet("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Modify","Installtime",RegBinary!,lbb_installdate[1]) //写入安装时间1
elseif ll_days<0 then
RegistrySet("HKEY_LOCAL_MACHINE\SOFTWARE\Modify","Installtime",RegBinary!,lbb_installdate[2]) //写入安装时间2
end if
if ll_days_count_down<>0 then
if ll_days>0 then
ll_days_diff=DaysAfter(ldate_installdate[1],ldate_systime)
elseif ll_days<0 then
ll_days_diff=DaysAfter(ldate_installdate[2],ldate_systime)
end if
if ll_days_diff>ll_days_count_down then
Messagebox('倒计时','倒计时'+string(ll_days_count_down)+'天完毕,系统停止运行!',Exclamation!,OK!)
Halt Close
end if
end if
else
if ls_installdate[1]='' then ll_installdateno=1
if ls_installdate[2]='' then ll_installdateno=2
if ls_installdate[1]='' and ls_installdate[2]='' then ll_installdateno=3

ls_installdate[1]=f_encrypt(string(date(creationtime)),0419) //安装时间1,加密字符串
ls_installdate[2]=ls_installdate[1] //安装时间2
for i=1 to 2
lbb_installdate[i]=blob(ls_installdate[i])
next
if ll_installdateno=1 or ll_installdateno=3 then
RegistrySet("HKEY_LOCAL_MACHINE\SOFTWARE\Modify","Installtime",RegBinary!,lbb_installdate[1]) //写入安装时间1
end if
if ll_installdateno=2 or ll_installdateno=3 then
RegistrySet("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Modify","Installtime",RegBinary!,lbb_installdate[2]) //写入安装时间2
end if
end if

//给系统日期赋值
ldate_sysdate=2009-10-31
IF Today()>ldate_sysdate THEN
MessageBox('日期过期','当前的日期已经超过'+string(ldate_sysdate),Exclamation!,OK!)
Halt Close
END IF

在close事件中代码如下:
string ls_pathname
Date ldate_lastacctime,ldate_recentdate,ldate_systime
blob lbb_recentdate
systemtime lstr_systemtime

//检查软件最近一次运行的时间
ls_pathname= GetCurrentDirectory() + "\test.exe"
uo_1.of_file_get_times( ls_pathname, creationtime, lastaccesstime, lastwritetime) //取文件时间

ldate_lastacctime=date(lastaccesstime) //取最后访问时间
GetLocalTime(lstr_systemtime) //取本地系统时间
ldate_systime=date(string(lstr_systemtime.year)+'-'+string(lstr_systemtime.month)+'-'+string(lstr_systemtime.day)) //本地系统时间
RegistryGet("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Modify","recenttime",RegBinary!,lbb_recentdate) //读取最近一次运行的时间
if string(lbb_recentdate)<>'' then ldate_recentdate=date(f_decrypt(string(lbb_recentdate),0419)) //解密字符串

if string(lbb_recentdate)='' then
lbb_recentdate=blob(f_encrypt(string(ldate_lastacctime),0419) ) //加密字符串
RegistrySet("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Modify","recenttime",RegBinary!,lbb_recentdate) //写入最近一次运行的时间
end if

if ldate_systime>ldate_recentdate then
lbb_recentdate=blob(f_encrypt(string(ldate_systime),0419)) //加密字符串
RegistrySet("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Modify","recenttime",RegBinary!,lbb_recentdate) //写入最近一次运行的时间
end if

这样即可,注意上面的f_encrypt和f_decrypt函数我并没有给大家,可以任找一段加密函数,密钥是0419,或者将加解密函数去掉。
Bull_Lee 2009-05-23
  • 打赏
  • 举报
回复
public function boolean of_file_set_times (string astr_pathname, datetime adt_creationtime, datetime adt_lastaccesstime, datetime adt_lastwritetime);constant ulong GENERIC_READ = 2147483648
constant ulong GENERIC_WRITE = 1073741824
constant ulong FILE_SHARE_READ = 1
constant ulong FILE_SHARE_WRITE = 2
constant ulong OPEN_EXISTING = 3
constant ulong FILE_ATTRIBUTE_ARCHIVE = 32

ulong lul_Null;SetNull(lul_Null)

long ll_Handle, ll_ErrorCode
SECURITY_ATTRIBUTES lsa_Temp
FILETIME lft_CreationTime, lft_LastAccessTime, lft_LastWriteTime, lft_Temp
SYSTEMTIME lst_CreationTime, lst_LastAccessTime, lst_LastWriteTime

lsa_Temp.nLength = 12;
lsa_Temp.lpSecurityDescriptor = lul_Null

lst_CreationTime.wYear = Year(Date(adt_CreationTime))
lst_CreationTime.wMonth = Month(Date(adt_CreationTime))
lst_CreationTime.wDayOfWeek = DayNumber(Date(adt_CreationTime)) - 1
lst_CreationTime.wDay = Day(Date(adt_CreationTime))
lst_CreationTime.wHour = Hour(Time(adt_CreationTime))
lst_CreationTime.wMinute = Minute(Time(adt_CreationTime))
lst_CreationTime.wSecond = Second(Time(adt_CreationTime))
lst_CreationTime.wMilliseconds = 0

If Not SystemTimeToFileTime(lst_CreationTime, lft_Temp) Then Return False
If Not LocalFileTimeToFileTime(lft_Temp, lft_CreationTime) Then Return False

lst_LastAccessTime.wYear = Year(Date(adt_LastAccessTime))
lst_LastAccessTime.wMonth = Month(Date(adt_LastAccessTime))
lst_LastAccessTime.wDayOfWeek = DayNumber(Date(adt_LastAccessTime)) - 1
lst_LastAccessTime.wDay = Day(Date(adt_LastAccessTime))
lst_LastAccessTime.wHour = Hour(Time(adt_LastAccessTime))
lst_LastAccessTime.wMinute = Minute(Time(adt_LastAccessTime))
lst_LastAccessTime.wSecond = Second(Time(adt_LastAccessTime))
lst_LastAccessTime.wMilliseconds = 0

If Not SystemTimeToFileTime(lst_LastAccessTime, lft_Temp) Then Return False
If Not LocalFileTimeToFileTime(lft_Temp, lft_LastAccessTime) Then Return False

lst_LastWriteTime.wYear = Year(Date(adt_LastWriteTime))
lst_LastWriteTime.wMonth = Month(Date(adt_LastWriteTime))
lst_LastWriteTime.wDayOfWeek = DayNumber(Date(adt_LastWriteTime)) - 1
lst_LastWriteTime.wDay = Day(Date(adt_LastWriteTime))
lst_LastWriteTime.wHour = Hour(Time(adt_LastWriteTime))
lst_LastWriteTime.wMinute = Minute(Time(adt_LastWriteTime))
lst_LastWriteTime.wSecond = Second(Time(adt_LastWriteTime))
lst_LastWriteTime.wMilliseconds = 0

If Not SystemTimeToFileTime(lst_LastWriteTime, lft_Temp) Then Return False
If Not LocalFileTimeToFileTime(lft_Temp, lft_LastWriteTime) Then Return False

ll_Handle = CreateFile(astr_PathName, GENERIC_WRITE, FILE_SHARE_READ + FILE_SHARE_WRITE, lsa_Temp, OPEN_EXISTING, FILE_ATTRIBUTE_ARCHIVE, lul_NULL)
If ll_Handle < 1 Then Return False

If Not SetFileTime(ll_Handle, lft_CreationTime, lft_LastAccessTime, lft_LastWriteTime) Then
CloseHandle(ll_Handle)
Return False
End If
CloseHandle(ll_Handle)

Return True

end function

on uo_file_function.create
call super::create
TriggerEvent( this, "constructor" )
end on

on uo_file_function.destroy
TriggerEvent( this, "destructor" )
call super::destroy
end on

将上面的代码存为uo_file_function.sru文件,再在pbl下点右键选import,将其导入,可实现读取文件和写入文件时间的问题,网上的方法有点小错误,我已将其改好。
然后在某个事件中调用方法如下:
先声明 uo_file_function uo_1 //声明读写文件时间的对象
DateTime creationtime,lastaccesstime,lastwritetime //文件创建时间,最近访问时间,最后修改时间
再调用 uo_1.of_file_get_times( ls_pathname, creationtime, lastaccesstime, lastwritetime) //读取文件时间
写入时间同上
Bull_Lee 2009-05-23
  • 打赏
  • 举报
回复
前几天在网上查了查,问题解决了,现在把代码发上来,供大家共享(主要是读取文件时间和写入文件时间的问题)

forward
global type uo_file_function from nonvisualobject
end type
type systemtime from structure within uo_file_function
end type
type filetime from structure within uo_file_function
end type
type security_attributes from structure within uo_file_function
end type
end forward

type SYSTEMTIME from structure
unsignedinteger wYear
unsignedinteger wMonth
unsignedinteger wDayOfWeek
unsignedinteger wDay
unsignedinteger wHour
unsignedinteger wMinute
unsignedinteger wSecond
unsignedinteger wMilliseconds
end type

type FILETIME from structure
unsignedlong dwLowDateTime
unsignedlong dwHighDateTime
end type

type SECURITY_ATTRIBUTES from structure
unsignedlong nLength
unsignedlong lpSecurityDescriptor
boolean bInheritHandle
end type

global type uo_file_function from nonvisualobject autoinstantiate
end type

type prototypes

Private Function boolean FileTimeToSystemTime(ref FILETIME lpFileTime, ref SYSTEMTIME lpSystemTime) Library "kernel32.dll"
Private Function boolean SystemTimeToFileTime(ref SYSTEMTIME lpSystemTime, ref FILETIME lpFileTime) Library "kernel32.dll"
Private Function boolean GetFileTime(ulong hFile, ref FILETIME lpCreationTime,ref FILETIME lpLastAccessTime, ref FILETIME lpLastWriteTime) Library "kernel32.dll"
Private Function boolean SetFileTime(ulong hFile, ref FILETIME lpCreationTime,ref FILETIME lpLastAccessTime, ref FILETIME lpLastWriteTime) Library "kernel32.dll"
Private Function ulong GetLastError() Library "kernel32.dll"
Private Function long CreateFile(ref string lpFileName, ulong dwDesiredAccess, ulong dwShareMode,ref SECURITY_ATTRIBUTES lpSecurityAttributes, ulong dwCreationDisposition, ulong dwFlagsAndAttributes, ulong hTemplateFile) Library "kernel32.dll" Alias for "CreateFileA;ANSI"
Private Function boolean FileTimeToLocalFileTime(ref FILETIME lpFileTime, ref FILETIME lpLocalFileTime) Library "kernel32.dll"
Private Function boolean LocalFileTimeToFileTime(ref FILETIME lpLocalFileTime, ref FILETIME lpFileTime) Library "kernel32.dll"
Private Function boolean CloseHandle(ulong hObject) Library "kernel32.dll"

end prototypes
type variables
constant string sDT_REMOVABLE = "REMOVABLE!"
constant string sDT_FIXED = "FIXED!"
constant string sDT_REMOTE = "REMOTE!"
constant string sDT_CDROM = "CDROM!"
constant string sDT_RAMDISK = "RAMDISK!"
end variables
forward prototypes
public function boolean of_file_get_times (string astr_pathname, ref datetime adt_creationtime, ref datetime adt_lastaccesstime, ref datetime adt_lastwritetime)
public function boolean of_file_set_times (string astr_pathname, datetime adt_creationtime, datetime adt_lastaccesstime, datetime adt_lastwritetime)
end prototypes

public function boolean of_file_get_times (string astr_pathname, ref datetime adt_creationtime, ref datetime adt_lastaccesstime, ref datetime adt_lastwritetime);constant ulong GENERIC_READ = 2147483648
constant ulong GENERIC_WRITE = 1073741824
constant ulong FILE_SHARE_READ = 1
constant ulong FILE_SHARE_WRITE = 2
constant ulong OPEN_EXISTING = 3
constant ulong FILE_ATTRIBUTE_ARCHIVE = 32

ulong lul_Null;SetNull(lul_Null)

long ll_Handle, ll_ErrorCode
SECURITY_ATTRIBUTES lsa_Temp
FILETIME lft_CreationTime, lft_LastAccessTime, lft_LastWriteTime, lft_Temp
SYSTEMTIME lst_CreationTime, lst_LastAccessTime, lst_LastWriteTime

lsa_Temp.nLength = 12;
lsa_Temp.lpSecurityDescriptor = lul_Null

ll_Handle = CreateFile(astr_PathName, GENERIC_READ, FILE_SHARE_READ + FILE_SHARE_WRITE, lsa_Temp, OPEN_EXISTING, FILE_ATTRIBUTE_ARCHIVE, lul_NULL)
If ll_Handle < 1 Then Return False
If Not GetFileTime(ll_Handle, lft_CreationTime, lft_LastAccessTime, lft_LastWriteTime) Then
CloseHandle(ll_Handle)
Return False
End If
CloseHandle(ll_Handle)

If Not FileTimeToLocalFileTime(lft_CreationTime, lft_Temp) Then Return False
If Not FileTimeToSystemTime(lft_Temp, lst_CreationTime) Then Return False

If Not FileTimeToLocalFileTime(lft_LastAccessTime, lft_Temp) Then Return False
If Not FileTimeToSystemTime(lft_Temp, lst_LastAccessTime) Then Return False

If Not FileTimeToLocalFileTime(lft_LastWriteTime, lft_Temp) Then Return False
If Not FileTimeToSystemTime(lft_Temp, lst_LastWriteTime) Then Return False

adt_CreationTime = DateTime(Date(string(lst_CreationTime.wYear) + "-" + string(lst_CreationTime.wMonth) + "-" + string(lst_CreationTime.wDay)), Time(string(lst_CreationTime.wHour) + ":" + string(lst_CreationTime.wMinute) + ":" + string(lst_CreationTime.wSecond) + ":" + string(lst_CreationTime.wMilliseconds)))
adt_LastAccessTime = DateTime(Date(string(lst_LastAccessTime.wYear) + "-" + string(lst_LastAccessTime.wMonth) + "-" + string(lst_LastAccessTime.wDay)), Time(string(lst_LastAccessTime.wHour) + ":" + string(lst_LastAccessTime.wMinute) + ":" + string(lst_LastAccessTime.wSecond) + ":" + string(lst_LastAccessTime.wMilliseconds)))
adt_LastWriteTime = DateTime(Date(string(lst_LastWriteTime.wYear) + "-" + string(lst_LastWriteTime.wMonth) + "-" + string(lst_LastWriteTime.wDay)), Time(string(lst_LastWriteTime.wHour) + ":" + string(lst_LastWriteTime.wMinute) + ":" + string(lst_LastWriteTime.wSecond) + ":" + string(lst_LastWriteTime.wMilliseconds)))

Return True


end function
Bull_Lee 2009-05-23
  • 打赏
  • 举报
回复
以上原理来自《加密与解密 第二版》第5章 5.3.2 时间限制一节,179页,由于PDF文档不能选取文本,所以我也就不摘抄了。上面源码绝对可靠,经调试通过。

谢谢版主和各位了,希望大家多回贴,给点建议。
WorldMobile 2009-05-23
  • 打赏
  • 举报
回复
比较有参考价值的文章,大家不要回复广告,否则杀无赦
newease 2009-05-23
  • 打赏
  • 举报
回复
感谢楼主给大家提供的方案和代码
llwinter 2009-05-23
  • 打赏
  • 举报
回复
学习ing
baggiolitao 2009-05-23
  • 打赏
  • 举报
回复
回帖是一种美德!每天回帖即可获得 10 分可用分!
WorldMobile 2009-05-23
  • 打赏
  • 举报
回复
给你加个精华,大家都来看看
happysky 2009-05-19
  • 打赏
  • 举报
回复
l_handle=CreateFile("c:\Windows\system32\nsuser.dat",1,1,lp_secattr,3,0,0)

1‘参数"c:\Windows\system32\nsuser.dat"使用变量进行参数传递,试试看
2、或者申明时将参数引用方式去掉再试试
FUNCTION ulong CreateFile(string lpFileName,ulong dwDesiredAccess,ulong dwShareMode,ref SECURITY_ATTRIBUTES lpSecurityAttributes, &
ulong dwCreationDisposition,ulong dwFlagsAndAttributes,ulong hTemplateFile) LIBRARY "kernel32.dll" ALIAS FOR "CreateFileA;Ansi"
woshilitao5 2009-05-19
  • 打赏
  • 举报
回复
頂一個!
Bull_Lee 2009-05-16
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 lzp_lrp 的回复:]
看一下你的createfile声明,是不是漏加了ANSI

FUNCTION ulong CreateFile(ref string lpFileName,ulong &
dwDesiredAccess,ulong dwShareMode,ref SECURITY_ATTRIBUTES &
lpSecurityAttributes,ulong dwCreationDisposition,ulong &
dwFlagsAndAttributes,ulong hTemplateFile) LIBRARY "kernel32.dll" ALIAS FOR
"CreateFileA"
改为

FUNCTION ulong CreateFile(ref string lpFileNam…
[/Quote]
createfile声明照你说的做了,但是怎样调用?

FUNCTION ulong CreateFile(ref string lpFileName,ulong dwDesiredAccess,ulong dwShareMode,ref SECURITY_ATTRIBUTES lpSecurityAttributes, &
ulong dwCreationDisposition,ulong dwFlagsAndAttributes,ulong hTemplateFile) LIBRARY "kernel32.dll" ALIAS FOR "CreateFileA;Ansi"

SECURITY_ATTRIBUTES lp_secattr

l_handle=CreateFile("c:\Windows\system32\nsuser.dat",1,1,lp_secattr,3,0,0)

保存出现“Error C0082:Reference argument must be a non-constant and non-readonly variable reference.”
怎么办?谁能帮帮我?
现在只等剩下文件句柄得不到了~~
WorldMobile 2009-05-16
  • 打赏
  • 举报
回复
看一下你的createfile声明,是不是漏加了ANSI

FUNCTION ulong CreateFile(ref string lpFileName,ulong &
dwDesiredAccess,ulong dwShareMode,ref SECURITY_ATTRIBUTES &
lpSecurityAttributes,ulong dwCreationDisposition,ulong &
dwFlagsAndAttributes,ulong hTemplateFile) LIBRARY "kernel32.dll" ALIAS FOR
"CreateFileA"
改为

FUNCTION ulong CreateFile(ref string lpFileName,ulong &
dwDesiredAccess,ulong dwShareMode,ref SECURITY_ATTRIBUTES &
lpSecurityAttributes,ulong dwCreationDisposition,ulong &
dwFlagsAndAttributes,ulong hTemplateFile) LIBRARY "kernel32.dll" ALIAS FOR
"CreateFileA;Ansi"
newease 2009-05-16
  • 打赏
  • 举报
回复
如果修改文件、注册表、系统时间等等措施通过恢复系统、监控注册表等方式都可以破解


建议最简的的限制时间、使用次数使用加密狗

价格仅10左右成本不高

680

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder API 调用
社区管理员
  • API 调用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧