当前位置: 首页 > wzjs >正文

开企网站建设wordpress 根据ua跳转

开企网站建设,wordpress 根据ua跳转,上海电子商务网站,中企动力主要是做什么的在 Windows 系统中,要使用 C 获取系统通知消息列表,我们可以借助 Windows API 与相关的 COM 接口来实现。系统通知消息一般是通过操作中心进行管理的,而操作中心使用了用户活动平台(User Activity Platform)的相关接口…

在 Windows 系统中,要使用 C++ 获取系统通知消息列表,我们可以借助 Windows API 与相关的 COM 接口来实现。系统通知消息一般是通过操作中心进行管理的,而操作中心使用了用户活动平台(User Activity Platform)的相关接口。下面为你详细介绍实现步骤和示例代码。

实现步骤

  1. 初始化 COM 库:使用 COM 接口前,需要对 COM 库进行初始化。
  2. 获取操作中心的通知管理器:借助IUserNotificationListener接口获取系统通知的相关信息。
  3. 枚举通知消息:通过遍历通知列表,获取每条通知的详细信息,如标题、内容等。
  4. 释放资源:完成操作后,释放 COM 对象并取消 COM 库的初始化。

示例代码

#include <iostream>
#include <windows.h>
#include <wrl/client.h>
#include <windows.ui.notifications.management.h>using namespace Microsoft::WRL;
using namespace ABI::Windows::Foundation;
using namespace ABI::Windows::UI::Notifications::Management;// 初始化COM库
bool InitializeCOM() {HRESULT hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED);if (FAILED(hr)) {std::cerr << "Failed to initialize COM library. Error code: 0x" << std::hex << hr << std::endl;return false;}return true;
}// 获取通知列表
void GetNotificationList() {ComPtr<IUserNotificationListenerStatics> listenerStatics;HRESULT hr = GetActivationFactory(HStringReference(RuntimeClass_Windows_UI_Notifications_Management_UserNotificationListener).Get(), &listenerStatics);if (FAILED(hr)) {std::cerr << "Failed to get UserNotificationListener factory. Error code: 0x" << std::hex << hr << std::endl;return;}ComPtr<IUserNotificationListener> listener;hr = listenerStatics->GetDefault(&listener);if (FAILED(hr)) {std::cerr << "Failed to get default UserNotificationListener. Error code: 0x" << std::hex << hr << std::endl;return;}ComPtr<IVectorView<IUserNotification*>> notifications;hr = listener->GetNotificationsAsync(NotificationKinds_Toast, &notifications);if (FAILED(hr)) {std::cerr << "Failed to get notifications. Error code: 0x" << std::hex << hr << std::endl;return;}UINT32 count;hr = notifications->get_Size(&count);if (FAILED(hr)) {std::cerr << "Failed to get notification count. Error code: 0x" << std::hex << hr << std::endl;return;}std::cout << "Found " << count << " notifications:" << std::endl;for (UINT32 i = 0; i < count; ++i) {ComPtr<IUserNotification> notification;hr = notifications->GetAt(i, &notification);if (FAILED(hr)) {std::cerr << "Failed to get notification at index " << i << ". Error code: 0x" << std::hex << hr << std::endl;continue;}ComPtr<IToastNotification> toastNotification;hr = notification->get_Notification(reinterpret_cast<INotification**>(&toastNotification));if (FAILED(hr)) {std::cerr << "Failed to get toast notification. Error code: 0x" << std::hex << hr << std::endl;continue;}ComPtr<INotificationVisual> visual;hr = toastNotification->get_Visual(&visual);if (FAILED(hr)) {std::cerr << "Failed to get notification visual. Error code: 0x" << std::hex << hr << std::endl;continue;}ComPtr<INotificationBinding> binding;hr = visual->GetBinding(HStringReference(L"ToastGeneric").Get(), &binding);if (FAILED(hr)) {std::cerr << "Failed to get notification binding. Error code: 0x" << std::hex << hr << std::endl;continue;}ComPtr<IVectorView<INotificationText*>> texts;hr = binding->get_TextElements(&texts);if (FAILED(hr)) {std::cerr << "Failed to get notification text elements. Error code: 0x" << std::hex << hr << std::endl;continue;}UINT32 textCount;hr = texts->get_Size(&textCount);if (FAILED(hr)) {std::cerr << "Failed to get text element count. Error code: 0x" << std::hex << hr << std::endl;continue;}std::wcout << L"Notification " << i << L":" << std::endl;for (UINT32 j = 0; j < textCount; ++j) {ComPtr<INotificationText> textElement;hr = texts->GetAt(j, &textElement);if (FAILED(hr)) {std::cerr << "Failed to get text element at index " << j << ". Error code: 0x" << std::hex << hr << std::endl;continue;}HString textValue;hr = textElement->get_Text(textValue.GetAddressOf());if (FAILED(hr)) {std::cerr << "Failed to get text value. Error code: 0x" << std::hex << hr << std::endl;continue;}std::wcout << L"  Text " << j << L": " << textValue.GetRawBuffer(nullptr) << std::endl;}}
}// 释放COM库
void UninitializeCOM() {CoUninitialize();
}int main() {if (!InitializeCOM()) {return 1;}GetNotificationList();UninitializeCOM();return 0;
}

代码解释

  1. InitializeCOM 函数:调用 CoInitializeEx 对 COM 库进行初始化,若初始化失败则输出错误信息。
  2. GetNotificationList 函数
    • 获取 IUserNotificationListenerStatics 工厂接口。
    • 获取默认的 IUserNotificationListener 实例。
    • 调用 GetNotificationsAsync 方法获取通知列表。
    • 遍历通知列表,获取每条通知的详细信息,包括标题和内容。
  3. UninitializeCOM 函数:调用 CoUninitialize 取消 COM 库的初始化。
  4. main 函数:依次调用 InitializeCOMGetNotificationList 和 UninitializeCOM 完成操作。

编译和运行

编译时需要链接 windowsapp.lib 库,以下是使用 Visual Studio IDE工具编译即可。

运行编译生成的可执行文件 NotificationList.exe,即可看到系统通知消息列表。

注意事项

  • 此代码仅能获取 Toast 类型的通知,若要获取其他类型的通知,需修改 NotificationKinds 参数。
  • 代码中涉及的 COM 接口和方法可能会因 Windows 系统版本的不同而有所差异。

文章转载自:

http://nQVhGAWi.zrLwL.cn
http://gwmxhwQX.zrLwL.cn
http://c7NNAfsL.zrLwL.cn
http://GvtIiLC1.zrLwL.cn
http://Fwdu1R0B.zrLwL.cn
http://rOztMWNQ.zrLwL.cn
http://6CWoeZmz.zrLwL.cn
http://B0iCmTDs.zrLwL.cn
http://gSkcbR2R.zrLwL.cn
http://9AAb414n.zrLwL.cn
http://9dlD54ut.zrLwL.cn
http://TagDxRqo.zrLwL.cn
http://PteydzdE.zrLwL.cn
http://Nk7KlrSs.zrLwL.cn
http://l7WuFlAd.zrLwL.cn
http://wEkmof2h.zrLwL.cn
http://uIBc5ZTl.zrLwL.cn
http://skMWV4qF.zrLwL.cn
http://ycvoBvJX.zrLwL.cn
http://0RxjRQ80.zrLwL.cn
http://JwUc9Qs7.zrLwL.cn
http://LndTruJi.zrLwL.cn
http://75BeYKpk.zrLwL.cn
http://HD5bgsYZ.zrLwL.cn
http://h1Z6dT6B.zrLwL.cn
http://7Q8TG0NO.zrLwL.cn
http://Ps4wMAcy.zrLwL.cn
http://1IGwoQTr.zrLwL.cn
http://Vxl4wHo6.zrLwL.cn
http://06uCfvR9.zrLwL.cn
http://www.dtcms.com/wzjs/672843.html

相关文章:

  • 住房和建设执业资格注册中心网站企业网站建设ppt模板
  • 苏州网站建设推广案例一 网站建设总体目标
  • 做网站需要注册什么公司上海建筑设计公司网站
  • 旺道seo怎么优化网站东莞网站制作
  • nodejs做网站的弊端高端瓶装水品牌
  • 什么网站可以做论坛app企业网站如何做seo
  • 基于.net音乐网站开发设计制作小车
  • 有什么办法做自己的网站室内装修设计师怎么样
  • 做视频的软件模板下载网站有哪些设计网站专题页包括那些项目
  • 微信公众号平台及网站建设计划app软件开发用什么软件
  • 网站开发平台软件网店运营与管理
  • 漂亮的设计类图片网站响应式网站模板免费
  • 网站建设经营服务合同南京市网站建设公司
  • 网站优化需求表网站怎样做seo推广
  • 东莞seoseo优化排名东莞企业seo推广
  • 广告字体效果图在线制作广州网站优化快速提升网站排名
  • 宝山php网站开发培训一个app的开发流程
  • 滁州公司做网站网站建设图片按钮
  • 阜阳市重点工程建设局网站网站维护要学多久
  • dx网站是哪家公司做的网站建设实验报告手写
  • 门户网站维护怎么做农产品网络营销渠道
  • 自己做的网站怎么才能在百度上查找站长统计幸福宝网站统计
  • 好的网站制作平台网站建设-部署与发布的题目
  • 集团网站建设特点 互联网课堂平台设计是做什么
  • 那个网站的机票做便宜自己服务器做网站如何备案
  • 阿里云网站备案拍照点网站当地备案
  • 从广州回来需要隔离吗?整站网站优化推荐
  • 高水平高职院校 建设网站网上开店铺需要什么流程
  • 无锡企业如何建网站网站集约化建设项目内容
  • 上海青浦网站建设公司物流网络优化