是否有可能检查Windows安装是否正版或不是以编程方式? 让我们只是说,我想检查从C,C + +,Java或Python的Windows 7。
这来自CodeProject,在C + +( 在Windows VC中检查Windows正版 )
#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; }
从这里开始 :这是一个VBScript
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
Java解决方案是使用Process
作为子进程运行C ++或VBScript解决方案。