whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1541)

Database (90)
Files (137)
Forms (107)
Graphic (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Math (76)
Misc (126)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

103 Visitors Online


 
...add a password to a paradox table?
Autor: Simon Grossenbacher
Homepage: http://www.swissdelphicenter.ch
[ Print tip ]  

Tip Rating (3):  
     


uses
  
Bde, SysUtils, dbtables, windows;


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, nilnilnil, False) DBIERR_NONE then Exit;
  if pTblDesc  nil then FreeMem(pTblDesc, SizeOf(CRTblDesc));
  Result := True;
end;


 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners