Change Paradox Password Dynamically

I have Paradox database files, and I want to let the user set a password for these files.  I can do it from Database Desktop, but the user cannot.  So, I want my program to do this for the user.  

Is it possible?
SuperSyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

intheCommented:
Hi
The following function should change (or add) a master password to the table,it is using the DbiDoRestructure()call:

procedure SetPassword(Tbl: TTable; Password: DbiName);
var
  hDb: hDbiDb;
  TblDesc: CRTblDesc;
  Dir: String;
begin
  SetLength(Dir, dbiMaxNameLen + 1);
  Tbl.Active := True;
  Check(DbiGetDirectory(Tbl.DBHandle, False, PChar(Dir)));
  SetLength(Dir, StrLen(PChar(Dir)));
  try
    FillChar(TblDesc, sizeof(CRTblDesc), #0);
    Tbl.DisableControls;
    Tbl.Close;
    Check(DbiOpenDatabase(nil, nil, dbiReadWrite, dbiOpenExcl, nil, 0, nil, nil, hDb));
    Check(DbiSetDirectory(hDb, PChar(Dir)));
    TblDesc.bProtected := True;
    TblDesc.szPassword := Password;
    StrPCopy(TblDesc.szTblName, Tbl.TableName);
    StrCopy(TblDesc.szTblType, szParadox);
    Check(DbiDoRestructure(hDb, 1, @TblDesc, nil, nil, nil, False));   finally
    Check(DbiCloseDatabase(hDb));
    Tbl.EnableControls;
  end;
end;


Regards Barry
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
intheCommented:
could probably also use the tsessions  AddPassword,GetPassword functions...
0
SuperSyAuthor Commented:
InThe/Barry;

Thank you very much for the answer --- I am evaluating the answer right now.  

AddPassword is actually to provide password to a Paradox database in order to gain access to it.   GetPassword is to popup an "Enter Password.." dialog box, I believe.  

Somehow, I never saw this BDE help before, although I seem to have always had it.  

I have a good feeling about this one, so please give me some time to try your procedure out...

Sy
0
Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

intheCommented:
no problem ,thanks for the addpassword info
 (note i rarely do database stuff so dont know the ins and outs of all the comps mostly what i pick up from other questions ;-)
0
SuperSyAuthor Commented:
InThe/Barry;

Works beautifully.  I still have not understood the procedure entirely, but I feel safe to give you my sincere gratitude and the points that are rightfully yours.  

Once again, thank you very much for your prompt answer proposal, and thank you for being a true expert.  

=)

Sy
0
intheCommented:
im glad it worked,nice to know the helps appreciated :-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.