Android smartphone

2009-10-12

..Add a password to paradox table.

Author: SwissDelphiCenter.ch

unit Unit2;

interface
uses
bde,SysUtils,dbtables,windows;

Function TablePasswort(var table: ttable; password:string) : boolean;


implementation


function
StrToOem(const AnsiStr: string): string;
begin
SetLength(Result, Length(AnsiStr));
if Length(Result) > 0 then
CharToOem(PChar(AnsiStr), PChar(Result));
end;


Function TablePasswort(var table: TTable; password:string) : boolean;
var pTblDesc : pCRTblDesc;
hDb : hDBIDb;

begin
Result := false;
with Table do

begin
if
Active and (not Exclusive) then Close;
if (not Exclusive) then Exclusive := True;
if (not Active) then Open;
hDB := DBHandle;
Close;
end;
GetMem(pTblDesc,SizeOf(CRTblDesc));
FillChar(pTblDesc^,SizeOf(CRTblDesc),0 );
with pTblDesc^ do

begin
StrPCopy(szTblName, StrToOem(table.tablename));
szTblType:= szParadox;
StrPCopy(szPassword, StrToOem(Password));
bPack := True;
bProtected := True;
end;
if DbiDoRestructure(hDb, 1, pTblDesc, nil, nil, nil, FALSE )<> DBIERR_NONE

then exit;
if pTblDesc <> nil then FreeMem(pTblDesc, SizeOf(CRTblDesc));
result := true;
end;

No comments: