Delphi provides better solutions for showing a messagebox.
I should use the MessageDlg function. The return value of the MessageDlg (and MessageBox) function indicates the users choice. So you when you place a yes button on the MessageDlg, the return value will be mrYes when the user presses the Yes button.
So your code would be like this:
var
ShouldClose: Boolean;
begin
if MessageDlg('Do you really want to quit?', mtConfirmation,
[mbYes, mbNo], 0) = mrYes then
ShouldClose := True
else
ShouldClose := False;
end;
You also want to close your application if the users chooses Yes.
When you have a normal Delphi VCL application you can implement the CloseQuery event of you mainform, the CloseQuery event is executed when you try to close your mainform (like clicking the closebutton) and has a variable CanClose. Setting CanClose to True means the MainForm is OK to close, setting it to false will prevent your mainform from closing:
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
CanClose := MessageDlg('Do you really want to quit?', mtConfirmation,
[mbYes, mbNo], 0) = mrYes;
end;