Read the registry to get the Windows system XP/7/8/10 type (using wcscmp compare wchar[] content)

Source: Internet
Author: User

Many scenarios are using GetVersion, GetVersionEx these two APIs to query the operating system version number to determine the current operating system is the Windows family which, before the Win10, this method is the line of the pass, But after the appearance of Win10, this method is not allowed to judge Win10.

Here is a way to read the registry, which has been verified to be feasible:

[CPP]View PlainCopy 
  1. Viewing the registry learn: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Nt\currentversion\currentversion
  2. XP System 5.1 is xp,6.0 for Vista and 2008, 6.1 for Win7, 6.2 Win8, 6.3 Win10
  3. Whether the WIN10 system
  4. BOOL IsSystemWin10 ()
  5. {
  6. //GetVersion () is not suitable for judging the WIN10 system
  7. //Open the registration form
  10. L"Software\\microsoft\\windows nt\\currentversion",
  11. 0,
  12. Key_all_access,
  13. &hkey);
  14. if (nret! = ERROR_SUCCESS)
  15. return false;
  16. //Get CurrentVersion "6.3"
  17. WCHAR szcurrentversion[100] = {0};
  18. DWORD dwsize = 100;
  19. DWORD type;
  20. Nret = REGQUERYVALUEEXW (HKey, L"CurrentVersion", Null,&type, (BYTE *) szcurrentversion, &dwsize);
  21. if (nret! = ERROR_SUCCESS)
  22. return false;
  23. if (wcscmp (szcurrentversion,l"6.3") ==0)
  24. return true;
  25. Else
  26. return false;
  27. }

September 20, 2016 first update


Read the registry to get the Windows system XP/7/8/10 type (using wcscmp compare wchar[] content)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.