实现 1.添加快捷方式 private void InstallShortcut(String shortcutPat
标签:
老端方,先看效果右下角的notification:
操纵中心的notification:
整体效果:
缺一不成,不然弹出的notification没法交互。
实现1.添加快捷方法
private void InstallShortcut(String shortcutPath, String exePath) { IShellLinkW newShortcut = (IShellLinkW)new CShellLink(); newShortcut.SetPath(exePath); IPropertyStore newShortcutProperties = (IPropertyStore)newShortcut; PropVariantHelper varAppId = new PropVariantHelper(); varAppId.SetValue(APP_ID); newShortcutProperties.SetValue(PROPERTYKEY.AppUserModel_ID, varAppId.Propvariant); PropVariantHelper varToastId = new PropVariantHelper(); varToastId.VarType = VarEnum.VT_CLSID; varToastId.SetValue(typeof(NotificationActivator).GUID); newShortcutProperties.SetValue(PROPERTYKEY.AppUserModel_ToastActivatorCLSID, varToastId.Propvariant); ShellHelpers.IPersistFile newShortcutSave = (ShellHelpers.IPersistFile)newShortcut; newShortcutSave.Save(shortcutPath, true); }2.注册com组件
private void RegisterComServer(String exePath) { string regString = String.Format("SOFTWARE\\Classes\\CLSID\\{{{0}}}\\LocalServer32", typeof(NotificationActivator).GUID); var key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(regString); key.SetValue(null, exePath); }这样ActionCenter就可以通过GUID找到你的exe文件。
3.设置通知的内容样式
通知的样式有很多种,图片、文字、按钮、输入框可以组合使用。详情见最下面的参考链接。
这里我贴出下我例子里的构造设置。
温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/36562.html