A plain C library to handle windows toast notifications.
Includes a console and a GUI sample demo.
This library is based on concepts derived from former work of Valentin-Gabriel Radu, but completely rewritten.
The main goal of the library is to hide the whole complex toast notification mechanisms inside library and making available to the user a couple of handles and few functions to register/unregister callback function and other 2 functions to create and destroy a notification manager.
The user must just supply the XML template for the toast in a memory string.
To speed-up compilation, and allow usage also un compilers that doesn't have windows runtime headers avalable, a condensated header is included will all required windows.runtime definitions. Also the runtime libraries, 32 and 64 bits versions, are supplied.
EDIT: Updated version and added VisualStudio project.
Download it from github (https://github.com/Frankie-PellesC/ToastLib/tree/main).
Hi Frankie,
Thanks, I managed to build and run the two examples on Windows 10. TestToastLib.exe expects 7 inputs from the user, is that OK?
Quote from: Vortex on November 21, 2023, 08:29:27 AM
Hi Frankie,
Thanks, I managed to build and run the two examples on Windows 10. TestToastLib.exe expects 7 inputs from the user, is that OK?
Hello Erol,
Yes in the sample it emits 7 notifications as you can see in the loop:
/*
* Show some sample notifications.
*/
for (int i=0; i<7; i++)
{
if (!fToastSendNotification(hToast, wszText))
{
PostQuitMessage(1);
break;
}
Sleep(250);
}
I made this to check all functionalities during the debug, bat you can reduce the number if you want.
After the toasts are showed try to click everywhere inside one of them, then write down something and click send on the second. Then you can close the main app and repeat previous actions again. You'll see that the app restarts by itself.
The same happens with the GUI demo, only here you decide to show a toast.
You can change the dialog adding other inputs, controls, etc. simply modifying the XML template.
As you can see you don't need to interact at any level with windows runtime, but only use functions and handles. ;)
To use toasts in your app you only need the library
ToastLib.lib and the header
ToastLib.h. ;D
Quote from: frankie on November 21, 2023, 12:15:31 AM
A plain C library to handle windows toast notifications.
Very very nice piece of work!
John Z
Frankie,
Thanks a ton for this! I managed to run the console and GUI samples on both Windows 10 21H2 and 24H2 IoT LTSC. Excellent work and a super nice API!
Hi Quin,
Nice to have a LTSC version. Have you tried to build any program using V13 on the 24H2 LTSC computer?
Currently V13 does not build on the standard version WIN 11 24H2, it would be nice to know if LTSC shows the same issue. Expect to see *** Error code: -1073741819 ***
John Z
Quote from: John Z on April 29, 2025, 11:17:55 AMHi Quin,
Nice to have a LTSC version. Have you tried to build any program using V13 on the 24H2 LTSC computer?
Currently V13 does not build on the standard version WIN 11 24H2, it would be nice to know if LTSC shows the same issue. Expect to see *** Error code: -1073741819 ***
John Z
Hi,
The Pelles compiler does do some weird things on that version of Windows. It builds apps just fine, but I have hklm\software\microsoft\windows\windows error reporting\DontShowUI set to 1 in the registry, and I see two "Pelles ISO C compiler has stopped working" dialogs before the build finishes. However, I think my BCX is using version 12 of Pelles.
When I'm on campus later with that laptop in front of me I'll do some actual tests of CC on version 13. I suspect we'll hit the same problem though, IoT LTSC is the same codebase as 24H2 without all the store apps, no copilot, and some other stuff.
Quote from: John Z on April 29, 2025, 11:17:55 AMHi Quin,
Nice to have a LTSC version. Have you tried to build any program using V13 on the 24H2 LTSC computer?
Currently V13 does not build on the standard version WIN 11 24H2, it would be nice to know if LTSC shows the same issue. Expect to see *** Error code: -1073741819 ***
John Z
Hi John,
You were correct, I do see that error on my Windows 11 IoT LTSC machine. I'm running Windows 11 24H2 (AMD64) build 26100.3775, and get the exact error you mentioned.
Hi Quin,
Quote from: Quin on April 29, 2025, 08:09:09 PM]
Hi John,
You were correct, I do see that error on my Windows 11 IoT LTSC machine. I'm running Windows 11 24H2 (AMD64) build 26100.3775, and get the exact error you mentioned.
That is unfortunate but in line with other win 11 24H2 systems. There are workarounds, but I think we all hope Pelle can implement a fix.
Appreciate the testing :)
John Z