password mesage box

With code below i work  with one password.

How should i changeit  to make it work with more passwords?
//// password
procedure tform2.controlpassword();
begin
  ThePassword:=('xyz');  //my  password
  if   richeditWriteOKpassword then
   //  nothing
  else begin
      PostMessage(Handle, InputBoxMessage, 0, 0);
      If InputBox('set editing','Password:','')=(ThePassword)
                Then  begin
     // richedit1.ReadOnly:=false;
      combobox1.Enabled:=true;
      combobox2.Enabled:=true;
      richeditWriteOKpassword:=true;
      richedit1.color:=clwhite;
        end;
    end;
end;
 
// *******************  pasword
procedure TForm2.InputBoxSetPasswordChar(var Msg: TMessage);
var
  hInputForm, hEdit, hButton: HWND;
 begin
  hInputForm := Screen.Forms[0].Handle;
  if (hInputForm <> 0) then
  begin
      hEdit := FindWindowEx(hInputForm, 0, 'TEdit', nil);
               // Change button text:
      hButton := FindWindowEx(hInputForm, 0, 'TButton', nil);
      SendMessage(hButton, WM_SETTEXT, 0, Integer(PChar('Cancel')));
      SendMessage(hEdit, EM_SETPASSWORDCHAR, Ord('*'), 0);
  end;
end;

Open in new window

pr2501Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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

Geert GOracle dbaCommented:
use an array
const 
  MaxPasswords = 2;
  Passwords: array[1..MaxPasswords] of string = ('xyz', 'abc');
 
procedure tform2.controlpassword();
var I: Integer;
  aPassword: string;
  Match: Boolean;
begin
  Match := False;
  repeat
    if   richeditWriteOKpassword then
      Match := True
    else 
    begin
      PostMessage(Handle, InputBoxMessage, 0, 0);
      aPassword := InputBox('set editing','Password:','');
      for I := 1 to MaxPasswords do 
        if aPassword = Passwords[I] then 
        begin
          Match := True;
          Break;
        end;
      if Match then 
      begin
        combobox1.Enabled:=true;
        combobox2.Enabled:=true;
        richeditWriteOKpassword:=true;
        richedit1.color:=clwhite;
      end 
      //else ShowMessage('Wrong password');
    end;
  until Match;
end;

Open in new window

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
pr2501Author Commented:
thank you
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.