前几天写程序,做文件大小效验防止破解。
虽然不能完全防止破解,但还是可以防一些菜鸟们的。
获取文件大小代码如下:
function TForm1.GetFileSizess(const FileName: string): Int64; var SR: TSearchRec; begin Result := -1; if FindFirst(FileName, faAnyFile and (not faDirectory), SR) = 0 then try Result := SR.Size; finally FindClose(SR); end; end;
使用时直接调用,代码如下:
if GetFileSizess(Application.Exename)= 487424 then //比较程序大小
您可以写复杂点,将大小字节加密后 解密来对比。这样可以有效防止菜鸟们直接用静态编辑工具修改大小来效验。
判断文件是否存在代码如下:
if FileExists('date.mdb') then
标签:delphi
发表评论