我正在使用下面的代码来确定 Windows7 的激活。我得到 7 个实例/产品。我不清楚哪个产品指的是原始 Windows 7。
我无法找到有关检查哪个实例以确定 Windows 是否已激活的文档
//use a SelectQuery to tell what we're searching in
SelectQuery searchQuery = new SelectQuery("SELECT * FROM SoftwareLicensingProduct");
//set the search up
ManagementObjectSearcher searcherObj = new ManagementObjectSearcher(scope, searchQuery);
//get the results into a collection
using (ManagementObjectCollection obj = searcherObj.Get())
{
foreach (ManagementObject m in obj)
{
if (Convert.ToInt32(m["GracePeriodRemaining"].ToString()) == 0)
{
MessageBox.Show("Windows is active");
break;
}
else
{
MessageBox.Show(" Windows is not active");
break;
}
}
//now loop through the collection looking for
//an activation status
}