以编程方式检查 Windows 7 是否已激活

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5859073/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 16:46:17  来源:igfitidea点击:

Programmatically check whether Windows 7 is activated

c#windowsauthenticationactivation

提问by Ryan R

Background:I am creating system images that will be loaded onto several workstations. Windows activation will occur after the images are loaded onto the workstation. These computers will not be connected to the Internet and will be activated over the phone.

背景:我正在创建将加载到多个工作站上的系统映像。将图像加载到工作站后将激活 Windows。这些计算机不会连接到 Internet,而是通过电话激活。

Question:I would like to check programmatically if Windows 7 is activated or not, so that our software will not run if Windows 7 is not activated. Our software is written in C#.

问题:我想以编程方式检查 Windows 7 是否已激活,以便在未激活 Windows 7 的情况下我们的软件将无法运行。我们的软件是用 C# 编写的。

采纳答案by Alex K.

The Software Licensing API - SLIAPI, take at look at SLIsGenuineLocal(). (Replaces LegitCheck)

Software Licensing API- SLIAPI,看看SLIsGenuineLocal()。(替换LegitCheck

回答by Pepe

You can run "Slmgr.vbs" on the machine and then redirect the output to check.

您可以在机器上运行“Slmgr.vbs”,然后重定向输出进行检查。

System.Diagnostics.Process.Start(@"cscript Slmgr.vbs > D:\log.txt");

This will return all the information you need. Not the cleanest way to do it though.

这将返回您需要的所有信息。虽然不是最干净的方法。

回答by BRaul

You may check HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows Activation Technologies\AdminObject\Store\TotalValidations and see if it is 1. This may not be the definative way to verify activation, but you should at least be abel to see if it was validated.

您可以检查 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows Activation Technologies\AdminObject\Store\TotalValidations 是否为 1。这可能不是验证激活的最终方法,但您至少应该看到如果它被验证。

回答by Brad Christie

Not sure if it applies to Win7, but I found a postthat checks XP for activation using a Win32_WindowsProductActivationclass.

不确定它是否适用于 Win7,但我发现了一篇使用Win32_WindowsProductActivation类检查 XP 是否激活的帖子

I'll build a test one on my machine (x64 Win7) and see if it returns activated or not, but at least gives you something to try out in the mean time.

我将在我的机器(x64 Win7)上构建一个测试,看看它是否返回激活状态,但至少同时给你一些可以尝试的东西。

EDIT(wish I kept reading the docs)A comment on that class page mentions that this class, on Win 7 and other versions) appears to be replaced with the Software Licensing Classes. I'll see if I can get a working result.

编辑(希望我继续阅读文档)该类页面上的评论提到该类,在 Win 7 和其他版本上)似乎被替换为Software Licensing Classes。我会看看我是否能得到一个有效的结果。

回答by Marco Concas

You can use this reference: https://github.com/Marko97IT/CWAIn the README.md you can find the download link.

您可以使用此参考:https: //github.com/Marko97IT/CWA在 README.md 中,您可以找到下载链接。