function LockupFile(FileName:string;Lock:boolean=true):integer; //加密、解密数据库,针对 Access 2000 var f:File; bf:array[0..63] of Byte; i:integer; const fpos=64; flen=64; //下面改为自己的密钥,我是用随机生成的,请改为自己的密钥 pw:array[0..63] of byte= ($97,$A0,$0C,$A1,$06,$59,$0A,$6D, $91,$33,$51,$57,$D4,$A3,$94,$16, $3D,$B2,$C7,$A0,$7C,$A3,$30,$EE, $34,$D6,$C1,$FF,$F7,$EC,$A5,$1F, $71,$2C,$19,$69,$E3,$25,$7D,$8B, $D3,$95,$AB,$C9,$02,$8A,$87,$44, $9F,$C7,$D7,$7D,$BA,$69,$56,$15, $FB,$CB,$03,$D6,$94,$A6,$BF,$F7); begin result:=-1; if not FileExists(FileName) then exit; try AssignFile(f,Filename); Reset(f,1); Seek(f,fpos); BlockRead(f,bf,flen); //下面的代码是判断是否被加密,你可以用二进制编辑器打开MDB文件对比, //我是用第64,65字节作为是否加密的标记,未加密与版本相关,加密后与版本和密钥相关 if lock and (bf[0]=$2B) and (bf[1]=$EE) or not lock and (bf[0]=$BC) and (bf[1]=$4E) or not ((bf[0]=$2B) and (bf[1]=$EE)) and not ((bf[0]=$BC) and (bf[1]=$4E)) then begin result:=0; exit; end; for i:=0 to flen-1 do bf[i]:=bf[i] xor pw[i mod 64]; Seek(f,fpos); BlockWrite(f,bf,flen); result:=1; finally CloseFile(f); end; end; function LockupFile(FileName:string;Lock:boolean=true):integer; //加密、解密数据库,针对 Access 2000 var f:File; bf:array[0..63] of Byte; i:integer; const fpos=64; flen=64; //下面改为自己的密钥,我是用随机生成的,请改为自己的密钥 pw:array[0..63] of byte= ($97,$A0,$0C,$A1,$06,$59,$0A,$6D, $91,$33,$51,$57,$D4,$A3,$94,$16, $3D,$B2,$C7,$A0,$7C,$A3,$30,$EE, $34,$D6,$C1,$FF,$F7,$EC,$A5,$1F, $71,$2C,$19,$69,$E3,$25,$7D,$8B, $D3,$95,$AB,$C9,$02,$8A,$87,$44, $9F,$C7,$D7,$7D,$BA,$69,$56,$15, $FB,$CB,$03,$D6,$94,$A6,$BF,$F7); begin result:=-1; if not FileExists(FileName) then exit; try AssignFile(f,Filename); Reset(f,1); Seek(f,fpos); BlockRead(f,bf,flen); //下面的代码是判断是否被加密,你可以用二进制编辑器打开MDB文件对比, //我是用第64,65字节作为是否加密的标记,未加密与版本相关,加密后与版本和密钥相关 if lock and (bf[0]=$2B) and (bf[1]=$EE) or not lock and (bf[0]=$BC) and (bf[1]=$4E) or not ((bf[0]=$2B) and (bf[1]=$EE)) and not ((bf[0]=$BC) and (bf[1]=$4E)) then begin result:=0; exit; end; for i:=0 to flen-1 do bf[i]:=bf[i] xor pw[i mod 64]; Seek(f,fpos); BlockWrite(f,bf,flen); result:=1; finally CloseFile(f); end; end;