如何让 Toast 通知留在 Windows 10 Action Center with Delphi
How to let a toast notification stay in Windows 10 Action Center with Delphi
我在Windows10中使用Delphi10.2,以下代码是Embarcadero提供的示例代码
在 运行 此代码之后,通知消失并且不再留在操作中心。我怎样才能让它挂在那里?
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;
添加:打开 Windows 设置 > 系统 > 通知和操作的开关后,我可以看到 HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Embarcadero.DesktopToasts.0579D43A\ShowInActionCenter 是 1。但是每个使用的用户这个应用程序不能一直手动执行此操作,我也无法预测密钥的名称。
你会在这里找到答案:
powershell script creates Windows 10 notification and it disappears after popup
您必须为 "Show notifications in action center" 注册您的应用程序
"HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings$prodName" -名称 "ShowInActionCenter" -类型 Dword -值“1”
要获取 $prodName 使用:
function TNotificationsForm.getRegisterToastMessageKey : String;
const
AppId = 'Embarcadero.DesktopToasts.';
begin
result := AppId + THashBobJenkins.GetHashString(ParamStr(0));
end;
Embarcadero 在这里做得不好,但是你得到了钥匙,
或复制单元 System.Win.Notification 并根据您的需要进行更改。
我在Windows10中使用Delphi10.2,以下代码是Embarcadero提供的示例代码
在 运行 此代码之后,通知消失并且不再留在操作中心。我怎样才能让它挂在那里?
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;
添加:打开 Windows 设置 > 系统 > 通知和操作的开关后,我可以看到 HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Embarcadero.DesktopToasts.0579D43A\ShowInActionCenter 是 1。但是每个使用的用户这个应用程序不能一直手动执行此操作,我也无法预测密钥的名称。
你会在这里找到答案: powershell script creates Windows 10 notification and it disappears after popup
您必须为 "Show notifications in action center" 注册您的应用程序 "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings$prodName" -名称 "ShowInActionCenter" -类型 Dword -值“1”
要获取 $prodName 使用:
function TNotificationsForm.getRegisterToastMessageKey : String;
const
AppId = 'Embarcadero.DesktopToasts.';
begin
result := AppId + THashBobJenkins.GetHashString(ParamStr(0));
end;
Embarcadero 在这里做得不好,但是你得到了钥匙, 或复制单元 System.Win.Notification 并根据您的需要进行更改。