开发者

How to check if a Windows version is Genuine or not?

Is开发者_运维问答 it possible to check whether a Windows installation is Genuine or not programmatically? Lets just say I want to check Windows 7 from C, C++, Java or Python.


this from CodeProject, in C++ ( Check for Windows Genuine in VC++ )

#include <slpublic.h>
#pragma comment(lib,"Slwga.lib")

bool IsWindowsGenuine()
{
    GUID uid;
    RPC_WSTR rpc=(RPC_WSTR)_T("55c92734-d682-4d71-983e-d6ec3f16059f");
    UuidFromString(rpc,&uid);
    SL_GENUINE_STATE state;
    SLIsGenuineLocal(&uid,&state,NULL);
    return state == SL_GENUINE_STATE::SL_GEN_STATE_IS_GENUINE;
}


From here: Here is a vbscript that does it

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colWPA = objWMIService.ExecQuery _
("Select * from Win32_WindowsProductActivation")
For Each objWPA in colWPA
Wscript.Echo "Activation Required: " & objWPA.ActivationRequired
Wscript.Echo "Description: " & objWPA.Description
Wscript.Echo "Product ID: " & objWPA.ProductID
Wscript.Echo "Remaining Evaluation Period: " & _
objWPA.RemainingEvaluationPeriod
Wscript.Echo "Remaining Grace Period: " & objWPA.RemainingGracePeriod
Wscript.Echo "Server Name: " & objWPA.ServerName
Next


The Java solution is to use Process to run the C++ or VBScript solution as a child process.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜