RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TSession.GetPassword Method

Invokes the OnPassword event handler for the session or displays the default password dialog box.

Pascal
function GetPassword: Boolean;
C++
__fastcall Boolean GetPassword();

Call GetPassword to invoke the OnPassword event handler for the session and handle response logic when an application is working with password-protected Paradox files. If an OnPassword event handler is not defined, GetPassword displays the default password dialog box. 

An application can use the return value of GetPassword to control program logic. GetPassword returns true if a user chooses OK, or false if the user chooses Cancel.

var
  rslt: Boolean;
begin
  rslt := Session.GetPassword;
try
if rslt then
      Table1.Open
else
      ShowMessage('No password given');
except
    ShowMessage('Could not open table!');
end;
ifnot Table1.Active then
    Application.Terminate;
end;

 

void __fastcall TForm1::OpenTableButtonClick(TObject *Sender)
{
bool rslt = Session->GetPassword();
try
  {
if (rslt)
      Table1->Open();
else
      ShowMessage("No password given");
  }
catch (...)
  {
    ShowMessage("Could not open table!");
  }
if (!Table1->Active)
    Application.Terminate();
}

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!