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?
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.

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);
  hDb: hDbiDb;
  TblDesc: CRTblDesc;
  Dir: String;
  SetLength(Dir, dbiMaxNameLen + 1);
  Tbl.Active := True;
  Check(DbiGetDirectory(Tbl.DBHandle, False, PChar(Dir)));
  SetLength(Dir, StrLen(PChar(Dir)));
    FillChar(TblDesc, sizeof(CRTblDesc), #0);
    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

Regards Barry

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
could probably also use the tsessions  AddPassword,GetPassword functions...
SuperSyAuthor Commented:

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...

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.

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 ;-)
SuperSyAuthor Commented:

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.  


im glad it worked,nice to know the helps appreciated :-)
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

From novice to tech pro — start learning today.