The documentation seems to be incorrect, this is the thread of the TTaskDialog.Execute method:
TTaskDialog.Execute â TCustomTaskDialog.Execute â TCustomTaskDialog.DoExecute â TaskDialogIndirect = S_OK?
As you can see, the result of the Execute method is true only if the TaskDialogIndirect function returns S_OK.
To evaluate the result of the dialog, you must use the ModalResult property.
with TTaskDialog.Create(Self) do begin try if Execute then case ModalResult of mrYes : ShowMessage('Success'); mrCancel : ShowMessage('Cancel'); else ShowMessage('Another button was pressed'); end; finally Free; end; end;
Note. If you close the dialog with the close button, mrCancel will be returned in the ModalResult property.
source share