c# - 以编程方式检查是否安装了 Windows Messaging?

标签 c# windows messaging

有没有一种简单的方法可以使用 C# 在 Windows 中检测消息传递组件是否已安装以及服务是否正在运行?

最佳答案

可以通过执行 WMI 查询来检查服务是否存在及其状态:

// Setup the query
ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2",
                    "SELECT * FROM Win32_Service WHERE Name = 'Blah'");

// Execute the query and enumerate the objects
foreach (ManagementObject queryObj in searcher.Get())
{
   // examine the query results to find the info you need.  For example:
    string name = (string)queryObj["Name"];
    bool started = (bool)queryObj["Started"];
    string status = (string)queryObj["Status"];
}

有关 WMI Win32_Service 类的更多信息,请参阅 here.

关于c# - 以编程方式检查是否安装了 Windows Messaging?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2630580/

相关文章:

windows - 轻松任务,windows提示批处理文件

javascript - ontouchstart 无法在 Windows 8 平板电脑上运行

java - SMPP 服务器 CloudHopper - 我应该如何接收多部分消息?

php - PHP/MySQL 消息系统

javascript - 如何在各种平台上启动聊天客户端应用程序

c# - MongoDB C# 驱动程序 - 更改继承类的 Id 序列化

c# - 编译时树结构

c# - 从基类一般初始化派生类字段的可靠方法?

c# - 如何获取刚刚添加到 DataTable 的行的标识?

c++ - 报告 ListView 中的气球式工具提示中错误的词干位置