我的delphi中公共function (2000年12月28日)
网友更新 分类:数据库 作者:saoren 推荐:saoren 阅读次数:562
(http://www.codesky.net)
--------------------------------------------------------------------------------
得到Access97的密码:
function GetAccessPassword(FilePath:string):string;
const
xorString:array[0..12]of byte=
( $86, $FB, $EC, $37,
$5D, $44, $9C, $FA,
$C6, $5E, $28, $E6,$13 );
var
passBuf:array[0..14]of byte;
pass:array[0..14]of char;
resultPass:string;
B:Byte;
F:TFileStream;
i:integer;
begin
F:=TFileStream.Create(FilePath,fmShareDenyNone);
//office 97
try
F.Seek($42,soFromBeginning);
F.Read(passBuf,14);
for I:=0 to 13 do
begin
B := passBuf[i] xor xorString[i];
pass[i]:=char(B);
end;
pass[sizeof(pass) - 1] := #0;
resultPass:=StrPas(Pass);
finally
F.Free;
end;
result:=resultPass;
end;
另外一个,是过滤string
如:str:='aa,dd,dd,cc,,jjj'
那么str:=GetMaskString(str,',',1);
str将会等于'aa';
类推。
function GetMaskString(S,Mask:string;Position:integer):string;
var Str:string;
i,Len:integer;
begin
Str:='';
for i:=0 to Position -1 do
begin
if (Pos(Mask,S) begin
Str:=S;
Break;
end;
Str:=Copy(S,1,Pos(Mask,S)-1);
Len:=Length(Str);
S:=Copy(S,Len+2,Length(S)-Len-1);
end;
Result:=Str;
end;
有用吧。哈哈。