' Find the path to the current executableĭim exePath As = Process.GetCurrentProcess().MainModule.FileNameĭim newShortcut As IShellLinkW = DirectCast(New CShellLink(), IShellLinkW) Private Sub InstallShortcut(shortcutPath As ) Private Function Tr圜reateShortcut() As Booleanĭim shortcutPath As = Environment.GetFolderPath() "\Microsoft\Windows\Start Menu\Programs\Desktop Toasts Sample CS.lnk" ' to make an installer that creates the necessary shortcut. ' Included in this project is a wxs file that be used with the WiX toolkit ' a shortcut and assign an AppUserModelID using Windows APIs. ' The shortcut should be created as part of the installer. ' Also, an AppUserModelID must be set on that shortcut. ' In order to display toasts, a desktop application must have a shortcut on the Start menu. Imports ĪddHandler ShowToastButton.Click, AddressOf ShowToastButton_Click Which seems to be a ref to Windows.Winmd whatever that is. Some issues have been reported trying to ref the Windows ref required. I also had removed the Public Sub New code and placed that code in the Form Load event with the exception of the AddHandler since it would not be necessary for using a standard Button click event handler with a And I replaced the Button click event with a Windows.Forms button click event in the app I created and copied the code below intoĮven though the code will not work on Win 7. And don't know if it will work since I don't have Win 8. I used Telerik to convert the code for the app to VB which is below. The binaries will need to be ref'd by the app to work. Will begin a download of a zip folder which contains a project, binaries, etc. Windows-API-Code-Pack-1.1 and at the link select "source (original)" which will take you to a new page where you can select "Windows API Code Pack 1.1.zip" that But I didn't do that as I downloaded it directly from here Dll's from the "Windows 7 API Code Pack" which you can get with NuGet. Sending toast notifications from desktop apps sample. 'Service provided by Telerik ('Conversion powered by NRefactory. ToastNotificationManager.CreateToastNotifier(APP_ID).Show(toast) Be sure to specify the AppUserModelId on your application's shortcut! ' Create the toast and attach event listenersĭim toast As New ToastNotification(toastXml) ImageElements(0).Attributes.GetNamedItem("src").NodeValue = imagePath StringElements(i).AppendChild(toastXml.CreateTextNode("Line " i))ĭim imagePath As = "file:///" Path.GetFullPath("toastImageAndText.png")ĭim imageElements As .XmlNodeList = toastXml.GetElementsByTagName("image") Private Const APP_ID As = ""ĭim toastXml As XmlDocument = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastImageAndText04)ĭim stringElements As .XmlNodeList = toastXml.GetElementsByTagName("text")įor i As Integer = 0 To stringElements.Length - 1 Code not tested as I don't have a Win 8 system. Try using online converters when necessary. Code would not convert in order it was in as errors occured. namespace - Minimum supported client = Windows 8Ĭode converted by Telerik. Windows.UI.Notifications namespace - Minimum supported client = Windows 8
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |