4

I'm running Windows 10 Professional 1809 build 17763.

The value of HKLM\SOFTWARE\ WOW6432Node\Microsoft\Windows NT\CurrentVersion\EditionID is "Enterprise", which is wrong. HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\EditionID is "Professional", which is correct.

Is this a specific problem with my Windows installation? If not, how would you solve it if you would develop in 32 bit?

My original code is in C++. Because I didn't understand the issue first, I reimplemented it in C#. I would appreciate solutions in C# or C++ and I'm confident that I can solve the issue in one language given a solution in the other language. Thank you!

using System;
using System.Collections.Generic;
using Microsoft.Win32;

class Program
{
    static void Main(string[] args) {
        List<string> valueNames = new List<string> { "ProductName", "EditionID" };
        foreach (var valueName in valueNames) {
            string value = (string)Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", valueName, "Key not found");
            Console.WriteLine($"{valueName}: {value}");
        }
    }
}
//---- C++ version
#include "Registry.hpp" // Modern C++ Wrappers for Win32 Registry Access APIs by Giovanni Dicanio

const std::wstring subKey{ L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion" };
const std::wstring value{ L"EditionID" };
std::wstring ws = win32::RegGetString(HKEY_LOCAL_MACHINE, subKey, value);
this->windowsEdition = std::string(ws.begin(), ws.end());

EditionID should be "Professional", but is "Enterprise".

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
Joe
  • 741
  • 1
  • 5
  • 6
  • I encounter exactly the same thing. I believe it has something to do with the reason we are registered to Domain Controller which is a Enterprise System. I have Release 1803. – Rolfi Mar 02 '19 at 11:57
  • 1
    I have the same problem with Windows 10 Pro. Even the "Product Name" is "Windows 10 Enterprise". Very weird. I think it is a bug that got never fixed. – Daniel Marschall Jul 29 '19 at 14:35
  • Same thing here. Win 10, 64, 1903, Pro (german). – Ralph Erdt Aug 09 '19 at 09:46

2 Answers2

4

To access the 64 bit tree in the registry from a 32 bit application, You have to open the registry key using the option KEY_WOW64_64KEY.

C / C++ Example:

error = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_QUERY_VALUE | KEY_WOW64_64KEY, &hKey);

Edit:

For .Net 3.5 or prior I found this: how-read-the-64-bit-registry-from-a-32-bit-application

Edit: C# (4.x) code:

RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64).
Ralph Erdt
  • 537
  • 4
  • 16
1

I too was facing this issue, but following Ralph suggestion, the editionID is coming correctly for professionals version also.

C# Code:

var key = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64).OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion");
var editionID = key.GetValue("EditionID");
suraj
  • 196
  • 1
  • 8