我开发了WinToast,这是一个用 C++ 编写的库,可以轻松集成 Windows Toast Notification。我用它在不同的项目中集成了 Toast 通知,特别是与 Qt 框架。
本机 Toast 通知需要Com Fundamentals的一些功能,这些功能 仅在现代版本的 Windows 中可用(支持的最低客户端:Windows 8)。
这就是库动态加载所有必需库的原因。使用 WinToast 使您的应用程序与旧版本的 Windows 兼容。有一个附加示例解释如何在存储库中使用它。
要显示祝酒词,只需创建模板和您的自定义处理程序并启动它:
WinToastHandlerExample* handler = new WinToastHandlerExample;
WinToastTemplate templ = WinToastTemplate(WinToastTemplate::ImageWithTwoLines);
templ.setImagePath(L"C:/example.png");
templ.setTextField(L"title", WinToastTemplate::FirstLine);
templ.setTextField(L"subtitle", WinToastTemplate::SecondLine);
if (!WinToast::instance()->showToast(templ, handler)) {
std::wcout << L"Could not launch your toast notification!";
}