This site is temporarily down. Please come back. Assign a password to a Paradox table
DelphiFAQ Home Search:

Assign a password to a Paradox table

 

commentsThis article has not been rated yet. After reading, feel free to leave comments and rate it.

To assign a password to a Paradox table, use the following unit and call function TablePasswort like this:

uses Unit2;
// ..
TablePasswort (Table1, 'secret');

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; 


end.

Content-type: text/html

Comments:

2015-02-01, 00:29:19
anonymous from Belgium  
Was totally stuck until I read this, now back up and runngni.
2015-02-01, 21:45:32
anonymous from Venezuela  
Which came first, the problem or the sotouiln? Luckily it doesn't matter. http://unwyuojcdo.com [url= http://mdazzlbnke.c..bnke[/url] [link= http://igkfaya.com]..aya[/link]

 

 

NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.
 

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: