Habe gerade mal nachgeschaut:
Ich mache das so für eine Anwendung und funktioniert
Delphi-Quellcode:
procedure TAppForm.checkToastActionCenterKey(const StayInCenter: Integer);
const
cKeyname = 'Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\';
cActionKey = 'ShowInActionCenter';
var
Reg: TRegistry;
OpenResult: Boolean;
lKey: string;
begin
lKey := cKeyname + getRegisterToastMessage + '\';
Reg := TRegistry.Create(KEY_WRITE);
try
Reg.RootKey := HKEY_CURRENT_USER;
OpenResult := Reg.OpenKey(lKey, true);
if not OpenResult then
Exit();
{ Checking if the values exist and inserting when neccesary }
if not Reg.KeyExists(cActionKey) then
Reg.WriteInteger(cActionKey, StayInCenter); // else
Reg.CloseKey();
finally
Reg.Free;
end;
end;
function TAppForm.getRegisterToastMessage: string;
const
AppId = 'Embarcadero.DesktopToasts.';
begin
result := AppId + THashBobJenkinsGetHashString(ParamStr(0));
end;
procedure TAppForm.SendToastMessage(const Value: string);
var
MyNotification: TNotification;
begin
MyNotification := fNotification.CreateNotification;
try
MyNotification.Name := 'Fritz';
MyNotification.Title := 'MyTost';
MyNotification.AlertBody := Value;
MyNotification.AlertAction := '';;
MyNotification.HasAction := true;
fNotification.PresentNotification(MyNotification);
finally
MyNotification.Free;
end;
end;
procedure TAppForm.FormCreate(Sender: TObject);
begin
fNotification := TNotificationCenter.Create(self);
checkToastActionCenterKey(1);
end;
Habe aber System.Notifactions als Source im Projekt