-- v3: winecfg: Fix CurrentVersion registry string for Windows 10 and up. ntdll: Default to Windows 10. ntdll: Add Windows 11 version.
From: Hans Leidekker hans@codeweavers.com
--- dlls/ntdll/version.c | 8 +++++++- programs/winecfg/appdefaults.c | 1 + 2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/dlls/ntdll/version.c b/dlls/ntdll/version.c index 02544173096..30480d06fa6 100644 --- a/dlls/ntdll/version.c +++ b/dlls/ntdll/version.c @@ -55,6 +55,7 @@ typedef enum WIN8, /* Windows 8 */ WIN81, /* Windows 8.1 */ WIN10, /* Windows 10 */ + WIN11, /* Windows 11 */ NB_WINDOWS_VERSIONS } WINDOWS_VERSION;
@@ -170,7 +171,11 @@ static const RTL_OSVERSIONINFOEXW VersionData[NB_WINDOWS_VERSIONS] = sizeof(RTL_OSVERSIONINFOEXW), 10, 0, 18362, VER_PLATFORM_WIN32_NT, L"", 0, 0, VER_SUITE_SINGLEUSERTS, VER_NT_WORKSTATION, 0 }, - + /* WIN11 */ + { + sizeof(RTL_OSVERSIONINFOEXW), 10, 0, 22000, VER_PLATFORM_WIN32_NT, + L"", 0, 0, VER_SUITE_SINGLEUSERTS, VER_NT_WORKSTATION, 0 + }, };
static const struct { WCHAR name[12]; WINDOWS_VERSION ver; } version_names[] = @@ -201,6 +206,7 @@ static const struct { WCHAR name[12]; WINDOWS_VERSION ver; } version_names[] = { L"win8", WIN8 }, { L"win81", WIN81 }, { L"win10", WIN10 }, + { L"win11", WIN11 }, };
diff --git a/programs/winecfg/appdefaults.c b/programs/winecfg/appdefaults.c index 9e43eeb51c8..3f6b424fed6 100644 --- a/programs/winecfg/appdefaults.c +++ b/programs/winecfg/appdefaults.c @@ -49,6 +49,7 @@ struct win_version
static const struct win_version win_versions[] = { + { L"win11", L"Windows 11", 10, 0, 22000, VER_PLATFORM_WIN32_NT, L"", 0, 0, L"WinNT"}, { L"win10", L"Windows 10", 10, 0, 18362, VER_PLATFORM_WIN32_NT, L"", 0, 0, L"WinNT"}, { L"win81", L"Windows 8.1", 6, 3, 9600, VER_PLATFORM_WIN32_NT, L"", 0, 0, L"WinNT"}, { L"win8", L"Windows 8", 6, 2, 9200, VER_PLATFORM_WIN32_NT, L"", 0, 0, L"WinNT"},
From: Hans Leidekker hans@codeweavers.com
--- dlls/msi/tests/package.c | 66 +++++++++++++++++----------------- dlls/ntdll/version.c | 2 +- loader/wine.inf.in | 32 ++++++++--------- programs/winecfg/appdefaults.c | 2 +- 4 files changed, 51 insertions(+), 51 deletions(-)
diff --git a/dlls/msi/tests/package.c b/dlls/msi/tests/package.c index 05633c4b6df..cad396aa05a 100644 --- a/dlls/msi/tests/package.c +++ b/dlls/msi/tests/package.c @@ -2137,7 +2137,7 @@ static void test_condition(void) DeleteFileA(msifile); }
-static void check_prop(MSIHANDLE hpkg, const char *prop, const char *expect, int match_case) +static void check_prop(MSIHANDLE hpkg, const char *prop, const char *expect, int match_case, int todo_value) { char buffer[MAX_PATH] = "x"; DWORD sz = sizeof(buffer); @@ -2145,9 +2145,9 @@ static void check_prop(MSIHANDLE hpkg, const char *prop, const char *expect, int ok(!r, "'%s': got %u\n", prop, r); ok(sz == lstrlenA(buffer), "'%s': expected %u, got %lu\n", prop, lstrlenA(buffer), sz); if (match_case) - ok(!strcmp(buffer, expect), "'%s': expected '%s', got '%s'\n", prop, expect, buffer); + todo_wine_if (todo_value) ok(!strcmp(buffer, expect), "'%s': expected '%s', got '%s'\n", prop, expect, buffer); else - ok(!_stricmp(buffer, expect), "'%s': expected '%s', got '%s'\n", prop, expect, buffer); + todo_wine_if (todo_value) ok(!_stricmp(buffer, expect), "'%s': expected '%s', got '%s'\n", prop, expect, buffer); }
static void test_props(void) @@ -2220,29 +2220,29 @@ static void test_props(void)
r = MsiSetPropertyA( hpkg, "=", "asdf" ); ok(!r, "got %u\n", r); - check_prop(hpkg, "=", "asdf", 1); + check_prop(hpkg, "=", "asdf", 1, 0);
r = MsiSetPropertyA( hpkg, " ", "asdf" ); ok(!r, "got %u\n", r); - check_prop(hpkg, " ", "asdf", 1); + check_prop(hpkg, " ", "asdf", 1, 0);
r = MsiSetPropertyA( hpkg, "'", "asdf" ); ok(!r, "got %u\n", r); - check_prop(hpkg, "'", "asdf", 1); + check_prop(hpkg, "'", "asdf", 1, 0);
/* set empty values */ r = MsiSetPropertyA( hpkg, "boo", NULL ); ok(!r, "got %u\n", r); - check_prop(hpkg, "boo", "", 1); + check_prop(hpkg, "boo", "", 1, 0);
r = MsiSetPropertyA( hpkg, "boo", "" ); ok(!r, "got %u\n", r); - check_prop(hpkg, "boo", "", 1); + check_prop(hpkg, "boo", "", 1, 0);
/* set a non-empty value */ r = MsiSetPropertyA( hpkg, "boo", "xyz" ); ok(!r, "got %u\n", r); - check_prop(hpkg, "boo", "xyz", 1); + check_prop(hpkg, "boo", "xyz", 1, 0);
r = MsiGetPropertyA(hpkg, "boo", NULL, NULL); ok(!r, "got %u\n", r); @@ -2317,10 +2317,10 @@ static void test_props(void) ok(sz == 3, "got size %lu\n", sz);
/* properties are case-sensitive */ - check_prop(hpkg, "BOO", "", 1); + check_prop(hpkg, "BOO", "", 1, 0);
/* properties set in Property table should work */ - check_prop(hpkg, "MetadataCompName", "Photoshop.dll", 1); + check_prop(hpkg, "MetadataCompName", "Photoshop.dll", 1, 0);
MsiCloseHandle( hpkg ); DeleteFileA(msifile); @@ -5734,70 +5734,70 @@ static void test_installprops(void) GetNativeSystemInfo(&si);
sprintf(buf, "%d", LOBYTE(LOWORD(GetVersion())) * 100 + HIBYTE(LOWORD(GetVersion()))); - check_prop(hpkg, "VersionNT", buf, 1); + check_prop(hpkg, "VersionNT", buf, 1, 1);
if (S(U(si)).wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) { sprintf(buf, "%d", si.wProcessorLevel); - check_prop(hpkg, "Intel", buf, 1); - check_prop(hpkg, "MsiAMD64", buf, 1); - check_prop(hpkg, "Msix64", buf, 1); + check_prop(hpkg, "Intel", buf, 1, 0); + check_prop(hpkg, "MsiAMD64", buf, 1, 0); + check_prop(hpkg, "Msix64", buf, 1, 0); sprintf(buf, "%d", LOBYTE(LOWORD(GetVersion())) * 100 + HIBYTE(LOWORD(GetVersion()))); - check_prop(hpkg, "VersionNT64", buf, 1); + check_prop(hpkg, "VersionNT64", buf, 1, 1);
GetSystemDirectoryA(path, MAX_PATH); strcat(path, "\"); - check_prop(hpkg, "System64Folder", path, 0); + check_prop(hpkg, "System64Folder", path, 0, 0);
GetSystemWow64DirectoryA(path, MAX_PATH); strcat(path, "\"); - check_prop(hpkg, "SystemFolder", path, 0); + check_prop(hpkg, "SystemFolder", path, 0, 0);
size = MAX_PATH; r = RegQueryValueExA(pathkey, "ProgramFilesDir (x86)", 0, &type, (BYTE *)path, &size); strcat(path, "\"); - check_prop(hpkg, "ProgramFilesFolder", path, 0); + check_prop(hpkg, "ProgramFilesFolder", path, 0, 0);
size = MAX_PATH; RegQueryValueExA(pathkey, "ProgramFilesDir", 0, &type, (BYTE *)path, &size); strcat(path, "\"); - check_prop(hpkg, "ProgramFiles64Folder", path, 0); + check_prop(hpkg, "ProgramFiles64Folder", path, 0, 0);
size = MAX_PATH; RegQueryValueExA(pathkey, "CommonFilesDir (x86)", 0, &type, (BYTE *)path, &size); strcat(path, "\"); - check_prop(hpkg, "CommonFilesFolder", path, 0); + check_prop(hpkg, "CommonFilesFolder", path, 0, 0);
size = MAX_PATH; RegQueryValueExA(pathkey, "CommonFilesDir", 0, &type, (BYTE *)path, &size); strcat(path, "\"); - check_prop(hpkg, "CommonFiles64Folder", path, 0); + check_prop(hpkg, "CommonFiles64Folder", path, 0, 0); } else if (S(U(si)).wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL) { sprintf(buf, "%d", si.wProcessorLevel); - check_prop(hpkg, "Intel", buf, 1); + check_prop(hpkg, "Intel", buf, 1, 0);
GetSystemDirectoryA(path, MAX_PATH); strcat(path, "\"); - check_prop(hpkg, "SystemFolder", path, 0); + check_prop(hpkg, "SystemFolder", path, 0, 0);
size = MAX_PATH; RegQueryValueExA(pathkey, "ProgramFilesDir", 0, &type, (BYTE *)path, &size); strcat(path, "\"); - check_prop(hpkg, "ProgramFilesFolder", path, 0); + check_prop(hpkg, "ProgramFilesFolder", path, 0, 0);
size = MAX_PATH; RegQueryValueExA(pathkey, "CommonFilesDir", 0, &type, (BYTE *)path, &size); strcat(path, "\"); - check_prop(hpkg, "CommonFilesFolder", path, 0); - - check_prop(hpkg, "MsiAMD64", "", 1); - check_prop(hpkg, "Msix64", "", 1); - check_prop(hpkg, "VersionNT64", "", 1); - check_prop(hpkg, "System64Folder", "", 0); - check_prop(hpkg, "ProgramFiles64Dir", "", 0); - check_prop(hpkg, "CommonFiles64Dir", "", 0); + check_prop(hpkg, "CommonFilesFolder", path, 0, 0); + + check_prop(hpkg, "MsiAMD64", "", 1, 0); + check_prop(hpkg, "Msix64", "", 1, 0); + check_prop(hpkg, "VersionNT64", "", 1, 0); + check_prop(hpkg, "System64Folder", "", 0, 0); + check_prop(hpkg, "ProgramFiles64Dir", "", 0, 0); + check_prop(hpkg, "CommonFiles64Dir", "", 0, 0); }
CloseHandle(hkey1); diff --git a/dlls/ntdll/version.c b/dlls/ntdll/version.c index 30480d06fa6..3a903c54c6b 100644 --- a/dlls/ntdll/version.c +++ b/dlls/ntdll/version.c @@ -473,7 +473,7 @@ void version_init(void)
NtQuerySystemInformation( SystemWineVersionInformation, wine_version, sizeof(wine_version), NULL );
- current_version = &VersionData[WIN7]; + current_version = &VersionData[WIN10];
RtlOpenCurrentUser( KEY_ALL_ACCESS, &root ); attr.Length = sizeof(attr); diff --git a/loader/wine.inf.in b/loader/wine.inf.in index f1525c4f6dd..3c9cb9bc6dc 100644 --- a/loader/wine.inf.in +++ b/loader/wine.inf.in @@ -2453,13 +2453,12 @@ HKLM,"System\CurrentControlSet\Services\Winsock\Parameters",,16 HKLM,"System\CurrentControlSet\Services\Winsock2\Parameters\Protocol_Catalog9\Catalog_Entries",,16
[VersionInfo] -HKLM,%CurrentVersionNT%,"CurrentVersion",2,"6.1" -HKLM,%CurrentVersionNT%,"CurrentMajorVersionNumber",0x10001,6 -HKLM,%CurrentVersionNT%,"CurrentMinorVersionNumber",0x10001,1 -HKLM,%CurrentVersionNT%,"CSDVersion",2,"Service Pack 1" -HKLM,%CurrentVersionNT%,"CurrentBuild",2,"7601" -HKLM,%CurrentVersionNT%,"CurrentBuildNumber",2,"7601" -HKLM,%CurrentVersionNT%,"CurrentType",2,"Uniprocessor Free" +HKLM,%CurrentVersionNT%,"CurrentVersion",2,"6.3" +HKLM,%CurrentVersionNT%,"CurrentMajorVersionNumber",0x10001,10 +HKLM,%CurrentVersionNT%,"CurrentMinorVersionNumber",0x10001,0 +HKLM,%CurrentVersionNT%,"CurrentBuild",2,"18362" +HKLM,%CurrentVersionNT%,"CurrentBuildNumber",2,"18362" +HKLM,%CurrentVersionNT%,"CurrentType",2,"Multiprocessor Free" HKLM,%CurrentVersionNT%,"DigitalProductId",1,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ @@ -2467,17 +2466,18 @@ HKLM,%CurrentVersionNT%,"DigitalProductId",1,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 -HKLM,%CurrentVersionNT%,"ProductName",2,"Microsoft Windows 7" +HKLM,%CurrentVersionNT%,"ProductName",2,"Windows 10 Pro" HKLM,%Control%\ProductOptions,"ProductType",2,"WinNT" -HKLM,%Control%\Windows,"CSDVersion",0x10003,0x100 +HKLM,%Control%\Windows,"CSDVersion",0x10003,0 HKLM,%Control%\Session Manager\Environment,"OS",2,"Windows_NT"
[VersionInfo.ntamd64] -HKLM,%CurrentVersionNT%,"CurrentVersion",2,"6.1" -HKLM,%CurrentVersionNT%,"CSDVersion",2,"Service Pack 1" -HKLM,%CurrentVersionNT%,"CurrentBuild",2,"7601" -HKLM,%CurrentVersionNT%,"CurrentBuildNumber",2,"7601" -HKLM,%CurrentVersionNT%,"CurrentType",2,"Uniprocessor Free" +HKLM,%CurrentVersionNT%,"CurrentVersion",2,"6.3" +HKLM,%CurrentVersionNT%,"CurrentMajorVersionNumber",0x10001,10 +HKLM,%CurrentVersionNT%,"CurrentMinorVersionNumber",0x10001,0 +HKLM,%CurrentVersionNT%,"CurrentBuild",2,"18362" +HKLM,%CurrentVersionNT%,"CurrentBuildNumber",2,"18362" +HKLM,%CurrentVersionNT%,"CurrentType",2,"Multiprocessor Free" HKLM,%CurrentVersionNT%,"DigitalProductId",1,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ @@ -2485,9 +2485,9 @@ HKLM,%CurrentVersionNT%,"DigitalProductId",1,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\ 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 -HKLM,%CurrentVersionNT%,"ProductName",2,"Microsoft Windows 7" +HKLM,%CurrentVersionNT%,"ProductName",2,"Windows 10 Pro" HKLM,%Control%\ProductOptions,"ProductType",2,"WinNT" -HKLM,%Control%\Windows,"CSDVersion",0x10003,0x100 +HKLM,%Control%\Windows,"CSDVersion",0x10003,0 HKLM,%Control%\Session Manager\Environment,"OS",2,"Windows_NT"
[Wow64] diff --git a/programs/winecfg/appdefaults.c b/programs/winecfg/appdefaults.c index 3f6b424fed6..0e18d5d2c69 100644 --- a/programs/winecfg/appdefaults.c +++ b/programs/winecfg/appdefaults.c @@ -74,7 +74,7 @@ static const struct win_version win_versions[] = #endif };
-#define DEFAULT_WIN_VERSION L"win7" +#define DEFAULT_WIN_VERSION L"win10"
static const WCHAR szKey9x[] = L"Software\Microsoft\Windows\CurrentVersion"; static const WCHAR szKeyNT[] = L"Software\Microsoft\Windows NT\CurrentVersion";
From: Hans Leidekker hans@codeweavers.com
It no longer reflects the real OS major and minor version numbers. --- programs/winecfg/appdefaults.c | 88 +++++++++++++++++++++------------- 1 file changed, 55 insertions(+), 33 deletions(-)
diff --git a/programs/winecfg/appdefaults.c b/programs/winecfg/appdefaults.c index 0e18d5d2c69..b7a2dc44038 100644 --- a/programs/winecfg/appdefaults.c +++ b/programs/winecfg/appdefaults.c @@ -37,6 +37,7 @@ struct win_version { const WCHAR *szVersion; const WCHAR *szDescription; + const WCHAR *szCurrentVersion; DWORD dwMajorVersion; DWORD dwMinorVersion; DWORD dwBuildNumber; @@ -49,28 +50,28 @@ struct win_version
static const struct win_version win_versions[] = { - { L"win11", L"Windows 11", 10, 0, 22000, VER_PLATFORM_WIN32_NT, L"", 0, 0, L"WinNT"}, - { L"win10", L"Windows 10", 10, 0, 18362, VER_PLATFORM_WIN32_NT, L"", 0, 0, L"WinNT"}, - { L"win81", L"Windows 8.1", 6, 3, 9600, VER_PLATFORM_WIN32_NT, L"", 0, 0, L"WinNT"}, - { L"win8", L"Windows 8", 6, 2, 9200, VER_PLATFORM_WIN32_NT, L"", 0, 0, L"WinNT"}, - { L"win2008r2", L"Windows 2008 R2", 6, 1, 7601, VER_PLATFORM_WIN32_NT, L"Service Pack 1", 1, 0, L"ServerNT"}, - { L"win7", L"Windows 7", 6, 1, 7601, VER_PLATFORM_WIN32_NT, L"Service Pack 1", 1, 0, L"WinNT"}, - { L"win2008", L"Windows 2008", 6, 0, 6002, VER_PLATFORM_WIN32_NT, L"Service Pack 2", 2, 0, L"ServerNT"}, - { L"vista", L"Windows Vista", 6, 0, 6002, VER_PLATFORM_WIN32_NT, L"Service Pack 2", 2, 0, L"WinNT"}, - { L"win2003", L"Windows 2003", 5, 2, 3790, VER_PLATFORM_WIN32_NT, L"Service Pack 2", 2, 0, L"ServerNT"}, + { L"win11", L"Windows 11", L"6.3", 10, 0, 22000, VER_PLATFORM_WIN32_NT, L"", 0, 0, L"WinNT"}, + { L"win10", L"Windows 10", L"6.3", 10, 0, 18362, VER_PLATFORM_WIN32_NT, L"", 0, 0, L"WinNT"}, + { L"win81", L"Windows 8.1", NULL, 6, 3, 9600, VER_PLATFORM_WIN32_NT, L"", 0, 0, L"WinNT"}, + { L"win8", L"Windows 8", NULL, 6, 2, 9200, VER_PLATFORM_WIN32_NT, L"", 0, 0, L"WinNT"}, + { L"win2008r2", L"Windows 2008 R2", NULL, 6, 1, 7601, VER_PLATFORM_WIN32_NT, L"Service Pack 1", 1, 0, L"ServerNT"}, + { L"win7", L"Windows 7", NULL, 6, 1, 7601, VER_PLATFORM_WIN32_NT, L"Service Pack 1", 1, 0, L"WinNT"}, + { L"win2008", L"Windows 2008", NULL, 6, 0, 6002, VER_PLATFORM_WIN32_NT, L"Service Pack 2", 2, 0, L"ServerNT"}, + { L"vista", L"Windows Vista", NULL, 6, 0, 6002, VER_PLATFORM_WIN32_NT, L"Service Pack 2", 2, 0, L"WinNT"}, + { L"win2003", L"Windows 2003", NULL, 5, 2, 3790, VER_PLATFORM_WIN32_NT, L"Service Pack 2", 2, 0, L"ServerNT"}, #ifdef _WIN64 - { L"winxp64", L"Windows XP", 5, 2, 3790, VER_PLATFORM_WIN32_NT, L"Service Pack 2", 2, 0, L"WinNT"}, + { L"winxp64", L"Windows XP", NULL, 5, 2, 3790, VER_PLATFORM_WIN32_NT, L"Service Pack 2", 2, 0, L"WinNT"}, #else - { L"winxp", L"Windows XP", 5, 1, 2600, VER_PLATFORM_WIN32_NT, L"Service Pack 3", 3, 0, L"WinNT"}, - { L"win2k", L"Windows 2000", 5, 0, 2195, VER_PLATFORM_WIN32_NT, L"Service Pack 4", 4, 0, L"WinNT"}, - { L"winme", L"Windows ME", 4, 90, 3000, VER_PLATFORM_WIN32_WINDOWS, L" ", 0, 0, L""}, - { L"win98", L"Windows 98", 4, 10, 2222, VER_PLATFORM_WIN32_WINDOWS, L" A ", 0, 0, L""}, - { L"win95", L"Windows 95", 4, 0, 950, VER_PLATFORM_WIN32_WINDOWS, L"", 0, 0, L""}, - { L"nt40", L"Windows NT 4.0", 4, 0, 1381, VER_PLATFORM_WIN32_NT, L"Service Pack 6a", 6, 0, L"WinNT"}, - { L"nt351", L"Windows NT 3.51", 3, 51, 1057, VER_PLATFORM_WIN32_NT, L"Service Pack 5", 5, 0, L"WinNT"}, - { L"win31", L"Windows 3.1", 3, 10, 0, VER_PLATFORM_WIN32s, L"Win32s 1.3", 0, 0, L""}, - { L"win30", L"Windows 3.0", 3, 0, 0, VER_PLATFORM_WIN32s, L"Win32s 1.3", 0, 0, L""}, - { L"win20", L"Windows 2.0", 2, 0, 0, VER_PLATFORM_WIN32s, L"Win32s 1.3", 0, 0, L""} + { L"winxp", L"Windows XP", NULL, 5, 1, 2600, VER_PLATFORM_WIN32_NT, L"Service Pack 3", 3, 0, L"WinNT"}, + { L"win2k", L"Windows 2000", NULL, 5, 0, 2195, VER_PLATFORM_WIN32_NT, L"Service Pack 4", 4, 0, L"WinNT"}, + { L"winme", L"Windows ME", NULL, 4, 90, 3000, VER_PLATFORM_WIN32_WINDOWS, L" ", 0, 0, L""}, + { L"win98", L"Windows 98", NULL, 4, 10, 2222, VER_PLATFORM_WIN32_WINDOWS, L" A ", 0, 0, L""}, + { L"win95", L"Windows 95", NULL, 4, 0, 950, VER_PLATFORM_WIN32_WINDOWS, L"", 0, 0, L""}, + { L"nt40", L"Windows NT 4.0", NULL, 4, 0, 1381, VER_PLATFORM_WIN32_NT, L"Service Pack 6a", 6, 0, L"WinNT"}, + { L"nt351", L"Windows NT 3.51", NULL, 3, 51, 1057, VER_PLATFORM_WIN32_NT, L"Service Pack 5", 5, 0, L"WinNT"}, + { L"win31", L"Windows 3.1", NULL, 3, 10, 0, VER_PLATFORM_WIN32s, L"Win32s 1.3", 0, 0, L""}, + { L"win30", L"Windows 3.0", NULL, 3, 0, 0, VER_PLATFORM_WIN32s, L"Win32s 1.3", 0, 0, L""}, + { L"win20", L"Windows 2.0", NULL, 2, 0, 0, VER_PLATFORM_WIN32s, L"Win32s 1.3", 0, 0, L""} #endif };
@@ -80,9 +81,20 @@ static const WCHAR szKey9x[] = L"Software\Microsoft\Windows\CurrentVersion"; static const WCHAR szKeyNT[] = L"Software\Microsoft\Windows NT\CurrentVersion"; static const WCHAR szKeyProdNT[] = L"System\CurrentControlSet\Control\ProductOptions";
+static DWORD get_reg_dword( HKEY root, const WCHAR *subkey, const WCHAR *value ) +{ + HKEY hkey; + DWORD ret, len = sizeof(ret), type; + + if (RegOpenKeyExW( root, subkey, 0, KEY_QUERY_VALUE, &hkey )) return 0; + if (RegQueryValueExW( hkey, value, NULL, &type, (BYTE *)&ret, &len ) || type != REG_DWORD) ret = 0; + RegCloseKey( hkey ); + return ret; +} + static int get_registry_version(void) { - int i, best = -1, platform, major, minor = 0, build = 0; + int i, best = -1, platform, major = 0, minor = 0, build = 0; WCHAR *p, *ver, *type = NULL;
if ((ver = get_reg_key( HKEY_LOCAL_MACHINE, szKeyNT, L"CurrentVersion", NULL ))) @@ -91,6 +103,9 @@ static int get_registry_version(void)
platform = VER_PLATFORM_WIN32_NT;
+ major = get_reg_dword( HKEY_LOCAL_MACHINE, szKeyNT, L"CurrentMajorVersionNumber" ); + minor = get_reg_dword( HKEY_LOCAL_MACHINE, szKeyNT, L"CurrentMinorVersionNumber" ); + build_str = get_reg_key( HKEY_LOCAL_MACHINE, szKeyNT, L"CurrentBuildNumber", NULL ); build = wcstol(build_str, NULL, 10);
@@ -101,19 +116,22 @@ static int get_registry_version(void) else return -1;
- if ((p = wcschr( ver, '.' ))) + if (!major) { - WCHAR *minor_str = p; - *minor_str++ = 0; - if ((p = wcschr( minor_str, '.' ))) + if ((p = wcschr( ver, '.' ))) { - WCHAR *build_str = p; - *build_str++ = 0; - build = wcstol(build_str, NULL, 10); + WCHAR *minor_str = p; + *minor_str++ = 0; + if ((p = wcschr( minor_str, '.' ))) + { + WCHAR *build_str = p; + *build_str++ = 0; + build = wcstol(build_str, NULL, 10); + } + minor = wcstol(minor_str, NULL, 10); } - minor = wcstol(minor_str, NULL, 10); + major = wcstol(ver, NULL, 10); } - major = wcstol(ver, NULL, 10);
for (i = 0; i < ARRAY_SIZE(win_versions); i++) { @@ -428,9 +446,13 @@ static void set_winver(const struct win_version *version) break;
case VER_PLATFORM_WIN32_NT: - swprintf(buffer, ARRAY_SIZE(buffer), L"%d.%d", version->dwMajorVersion, - version->dwMinorVersion); - set_reg_key(HKEY_LOCAL_MACHINE, szKeyNT, L"CurrentVersion", buffer); + if (version->szCurrentVersion) + set_reg_key(HKEY_LOCAL_MACHINE, szKeyNT, L"CurrentVersion", version->szCurrentVersion); + else + { + swprintf(buffer, ARRAY_SIZE(buffer), L"%d.%d", version->dwMajorVersion, version->dwMinorVersion); + set_reg_key(HKEY_LOCAL_MACHINE, szKeyNT, L"CurrentVersion", buffer); + } set_reg_key_dword(HKEY_LOCAL_MACHINE, szKeyNT, L"CurrentMajorVersionNumber", version->dwMajorVersion); set_reg_key_dword(HKEY_LOCAL_MACHINE, szKeyNT, L"CurrentMinorVersionNumber", version->dwMinorVersion); set_reg_key(HKEY_LOCAL_MACHINE, szKeyNT, L"CSDVersion", version->szCSDVersion);
Thanks, I've marked the test todo instead.