How do you protect an application with a password and store it in the application's exe-file?
You'd have to hard code the password in. Then in the FormCreate method of your main form, you'd do something like this:
procedure TForm1.FormCreate(Sender: TObject);
pwrd : String;
PassOK : Boolean;
Counter := 1;
PassOK := False;
while (Counter < 4) do begin
InputQuery('Type in a password',
'You have ' + IntToStr(4 - Counter) + ' tries left',
if (pwrd = 'MyPassword') then begin
PassOK := True;
if NOT PassOK then begin
ShowMessage('Exceeded maximum number of tries. ' +
'Press OK to terminate.');
This simple password validation gives the user three tries to come up with the correct password. You could be more elaborate by using a resource file with a string resource that is read at run time.