question

RudolfMeier-2283 avatar image
0 Votes"
RudolfMeier-2283 asked SongZhu-MSFT commented

detect Windows 10 edition

Hi...

I'm developing a software, that can only run on Windows 10 or Server 2016/2019 and not on the Home edition of Windows 10... now. What's the official way that Microsoft suggests to use to detect if I'm running on the correct system?

If possible, then I want to detect this during the setup... because... you know... crashing because I cannot initialize a component later or quitting with a Windows error message after the installation... that's... well, I don't like it... but, just for fun... what's the "Microsoft way" of doing this? Writing a compatiblity manifest and including this into the exe? What does it have to contain to prevent the app from running on Windows 10 Home? ...

Any ideas? ... not workarounds please... I can find those myself... but... Microsoft: "what's the official way to solve this problem?" ... every api I used in the past has been deprecated... so? solution... please? ...

Rudolf

windows-api
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

SongZhu-MSFT avatar image
0 Votes"
SongZhu-MSFT answered

You can use GetProductInfo.

Some code :

 #include <iostream>
 #include <windows.h>
 using namespace std;
    
 int main(int argc, const char* argv[])
 {
     DWORD dwPInfo = NULL;
     DWORD dwVersion = NULL;
     DWORD dwMajorVersion = NULL;
     DWORD dwMinorVersion = NULL;
     dwVersion = GetVersion();
     dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
     dwMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
     GetProductInfo(dwMajorVersion, dwMinorVersion, 0, 0, &dwPInfo);
     return 0;
 }




5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Castorix31 avatar image
0 Votes"
Castorix31 answered

From MS, Targeting your application for Windows

But in reality, tools like Winver just read the registry :

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion

And internally, APIs like VideoPortGetVersion use RtlGetVersion, like :

     HMODULE hDll = LoadLibrary(TEXT("Ntdll.dll"));
     typedef NTSTATUS(CALLBACK* RTLGETVERSION) (PRTL_OSVERSIONINFOW lpVersionInformation);
     RTLGETVERSION pRtlGetVersion;
     pRtlGetVersion = (RTLGETVERSION)GetProcAddress(hDll, "RtlGetVersion");
     if (pRtlGetVersion)
     {
         RTL_OSVERSIONINFOW ovi = { 0 };
         ovi.dwOSVersionInfoSize = sizeof(ovi);
         NTSTATUS ntStatus = pRtlGetVersion(&ovi);
         if (ntStatus == 0)
         {
             TCHAR wsBuffer[512];
             wsprintf(wsBuffer, TEXT("Major Version : %d - Minor Version : %d - Build Number : %d\r\n"), ovi.dwMajorVersion, ovi.dwMinorVersion, ovi.dwBuildNumber);
             OutputDebugString(wsBuffer);

             DWORD dwProductType = NULL;
             GetProductInfo(ovi.dwMajorVersion, ovi.dwMinorVersion, 0, 0, &dwProductType);
             // Test dwProductType
         }
     }



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RudolfMeier-2283 avatar image
0 Votes"
RudolfMeier-2283 answered SongZhu-MSFT commented

It's pretty amazing how difficult this is...

My problem is, that BitLocker needs to be available for my product and the local group policy has to be available. It seems, that's not available on the home edition of Windows 10... so, but... when I use the GetProductInfo function (which may be deprectated? but who knows that exactely... it might be... anyway, let's assume it is not) ... then I have 96 (!!!!!!!!!!!!!) documented values I could get back and I have not seen about 60 of them until now and 12 do have the word "home" in them. So... which of those do not have the BitLocker and a working local group policy?

... well, you can say now "That's wrong what you do! You should try to find an interface and when it's available, then it's ok!" ... ok, fine... let's try this one. The nice thing here is, that I get an error when I try to find the Win32_EncryptableVolume wmi class on a 2012 R2 server (because the feature is not installed, but ... you know, it could be, so ... my product should still install here) but... Windows 10 Home says "yup... available" :-) ... and the interfaces for the gpo manipulation ... I guess they're also working in the home edition... didn't check that, but... how should this help in identifying the system?

... ok then. What's the idea now? ... working with those 96 values and simply hoping, that it works in most cases? ... great... really great... and I wasted hours because of this!

Rudolf

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

As far as I know, there is no API to check whether Windows supports BitLocker/Local Group Policy, and I have not found that any Win10 Home supports them. The description of your problem is only how to check the Windows version, so I suggest you to check it according to different The windows version supports the conditions to filter.

0 Votes 0 ·