If you want to check if you are running on a Server Core edition of Windows you can use the GetProductInfo API.

GetProductInfo takes 4 input parameters that can be obtained using GetVersionEx and the OSVERSIONINFOEX structure:

No we call GetProductInfo:



The value returned in dwProdType can be checked against one of the constants for the Server Core editions:

So if put this all together we can write a function for it:

But where do these values come from?

GetProductInfo is exported by Kernel32.dll, this function is a stub to RtlGetProductInfo which is exported by ntdll.dll

RtlGetProductInfo performs a few checks on the input parameters and then calls the undocumented NtQueryLicenseValue API which has this signature:

The value of the Name parameter on my Windows 7 machine is Kernel-ProductInfo, the ulType parameter is SL_DATA_DWORD (4), the buffer is a PDWORD with Length being SizeOf(DWORD).

If the call to NtQueryLicenseValue fails, a special value of 0xABCDABCDu is returned which equals PRODUCT_UNLICENSED.

You can directly check this value with the Licensing Demo from my Having fun with Windows Licensing article: