diff options
author | nijtmans@users.sourceforge.net <jan.nijtmans> | 2014-02-04 08:35:02 (GMT) |
---|---|---|
committer | nijtmans@users.sourceforge.net <jan.nijtmans> | 2014-02-04 08:35:02 (GMT) |
commit | dab46a6705b54b0f5b2742335aaf4a8dcc8e1adc (patch) | |
tree | cf0025956d614590c4140bdf6c946af539fe20af /win | |
parent | 037c7cb5ccf8c3f6bb1f81a4b4045baf6ce2bae4 (diff) | |
download | tk-dab46a6705b54b0f5b2742335aaf4a8dcc8e1adc.zip tk-dab46a6705b54b0f5b2742335aaf4a8dcc8e1adc.tar.gz tk-dab46a6705b54b0f5b2742335aaf4a8dcc8e1adc.tar.bz2 |
Fix [http://core.tcl.tk/tcl/info/651e828a52|651e828a52]: Wrong Windows version reported for Windows 8.1
Diffstat (limited to 'win')
-rw-r--r-- | win/tkWinX.c | 29 |
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); } /* |