summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2014-02-04 08:35:02 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2014-02-04 08:35:02 (GMT)
commit6c6084d66c4ec111a3e3c9f4af5518d929313fef (patch)
tree063c791e55d86b9c923c8e536fe584a2c56e2d02
parent68c0b1ba3211be7946244c8d2b4db7d2c47d934f (diff)
downloadtk-6c6084d66c4ec111a3e3c9f4af5518d929313fef.zip
tk-6c6084d66c4ec111a3e3c9f4af5518d929313fef.tar.gz
tk-6c6084d66c4ec111a3e3c9f4af5518d929313fef.tar.bz2
Fix [http://core.tcl.tk/tcl/info/651e828a52|651e828a52]: Wrong Windows version reported for Windows 8.1
-rw-r--r--win/tkWinX.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/win/tkWinX.c b/win/tkWinX.c
index 60e5e90..a37fa0a 100644
--- a/win/tkWinX.c
+++ b/win/tkWinX.c
@@ -166,20 +166,31 @@ TkGetServerInfo(
Tk_Window tkwin) /* Token for window; this selects a particular
* display and server. */
{
- char buffer[60];
+ static char buffer[32]; /* Empty string means not initialized yet. */
OSVERSIONINFOW os;
- os.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
- GetVersionExW(&os);
- sprintf(buffer, "Windows %d.%d %d %s", (int)os.dwMajorVersion,
- (int)os.dwMinorVersion, (int)os.dwBuildNumber,
+ if (!buffer[0]) {
+ HANDLE handle = LoadLibraryW(L"NTDLL");
+ int(*getversion)(void *) = (int(*)(void *))GetProcAddress(handle, "RtlGetVersion");
+ os.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
+ if (!getversion || getversion(&os)) {
+ GetVersionExW(&os);
+ }
+ if (handle) {
+ FreeLibrary(handle);
+ }
+ /* Write the first character last, preventing multi-thread issues. */
+ sprintf(buffer+1, "indows %d.%d %d %s", (int)os.dwMajorVersion,
+ (int)os.dwMinorVersion, (int)os.dwBuildNumber,
#ifdef _WIN64
- "Win64"
+ "Win64"
#else
- "Win32"
+ "Win32"
#endif
- );
- Tcl_SetResult(interp, buffer, TCL_VOLATILE);
+ );
+ buffer[0] = 'W';
+ }
+ Tcl_SetResult(interp, buffer, TCL_STATIC);
}
/*