How to leave a notification in the Windows 10 Action Center using Delphi

I am using Delphi 10.2 on Windows 10. The following code is an example of the code provided by Embarcadero.

After running this code, the notification disappears and does not stop in the Action Center. How can I let this linger there?

procedure TNotify.btnShowClick(Sender: TObject);
var
  MyNotification: TNotification;
begin
  MyNotification := NotificationCenter1.CreateNotification;
  try
    MyNotification.Name := 'Windows10Notification';
    MyNotification.Title := 'Windows 10 Notification #1';
    MyNotification.AlertBody := 'RAD Studio 10 Seattle';

    NotificationCenter1.PresentNotification(MyNotification);
  finally
    MyNotification.Free;
  end;
end;

ADDED: after turning on the Windows settings switch> System> Notifications and actions, I see HKEY_CURRENT_USER \ Software \ Microsoft \ Windows \ CurrentVersion \ Notifications \ Settings \ Embarcadero.DesktopToasts.0579D43 \ AShowInActionCenter = 1. But every user who will use this application is not can do this all the time manually, and I also cannot predict the key name.

+6
1

: powershell script Windows 10

" " "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\\\$prodName" - "ShowInActionCenter" - Dword -Value "1"

$prodName:

function TNotificationsForm.getRegisterToastMessageKey : String;
const
  AppId = 'Embarcadero.DesktopToasts.';
begin
  result := AppId + THashBobJenkins.GetHashString(ParamStr(0));
end;

Embarcadero , , System.Win.Notification .

+4

All Articles