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.
Asked
Active
Viewed 2,320 times
3 Answers
2
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;
}

Billy ONeal
- 104,103
- 58
- 317
- 552

Davide Piras
- 43,984
- 10
- 98
- 147
-
8`if (expression) return true; [else] return false;` can be replaced by `return expression;` – fredoverflow Sep 25 '11 at 11:32
-
yeah, just copied from code project, did not write it myself :D – Davide Piras Sep 25 '11 at 11:34
-
2return state==SL_GENUINE_STATE::SL_GEN_STATE_IS_GENUINE; – Tim Sep 25 '11 at 21:07
-
1`SL_GENUINE_STATE` is an `enum`; using the enum name as a namespace is a Microsoft extension (and unnecessary). Just write `return state == SL_GEN_STATE_IS_GENUINE;` – MSalters Sep 26 '11 at 08:04
-
What is "55c92734-d682-4d71-983e-d6ec3f16059f" ? – anegru Aug 09 '19 at 11:40
1
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

Preet Sangha
- 64,563
- 18
- 145
- 216
0
The Java solution is to use Process
to run the C++ or VBScript solution as a child process.

Stephen C
- 698,415
- 94
- 811
- 1,216