C#查询WMI获得系统安装ID、激活ID

其中 ID 为激活ID,OfflineInstallationId为安装ID

直接贴代码:

using System;
using System.Management;

namespace WMISelect {
    class Program {
        static void Main(string[] args) {
            var officeSoftware = new ManagementObjectSearcher("SELECT ID, ApplicationId, PartialProductKey, LicenseIsAddon, Description, Name, OfflineInstallationId FROM SoftwareLicensingProduct where PartialProductKey <> null");
            var result = officeSoftware.Get();
            foreach (var item in result)
            {
                Console.WriteLine("Name:" + item.GetPropertyValue("Name"));
                Console.WriteLine("ApplicationID:" + item.GetPropertyValue("ApplicationID"));
                Console.WriteLine("Description:" + item.GetPropertyValue("Description"));
                Console.WriteLine("ID:" + item.GetPropertyValue("ID"));
                Console.WriteLine("LicenseIsAddon:" + item.GetPropertyValue("LicenseIsAddon"));
                Console.WriteLine("OfflineInstallationId:" + item.GetPropertyValue("OfflineInstallationId"));
                Console.WriteLine("PartialProductKey:" + item.GetPropertyValue("PartialProductKey"));
                Console.WriteLine();
            }
            Console.ReadKey();
        }
    }
}

参考文档:http://cuzic.net/wmi-yard-0.10/WMI/OfficeSoftwareProtectionProduct.html

9 Replies to “C#查询WMI获得系统安装ID、激活ID”

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据