[Ttssh2-commit] [4481] OS のバージョン確認を正しく行うように修正。

svnno****@sourc***** svnno****@sourc*****
2011年 6月 6日 (月) 22:20:00 JST


Revision: 4481
          http://sourceforge.jp/projects/ttssh2/svn/view?view=rev&revision=4481
Author:   doda
Date:     2011-06-06 22:20:00 +0900 (Mon, 06 Jun 2011)

Log Message:
-----------
OS のバージョン確認を正しく行うように修正。

Modified Paths:
--------------
    trunk/teraterm/teraterm/winjump.c


-------------- next part --------------
Modified: trunk/teraterm/teraterm/winjump.c
===================================================================
--- trunk/teraterm/teraterm/winjump.c	2011-06-06 00:55:49 UTC (rev 4480)
+++ trunk/teraterm/teraterm/winjump.c	2011-06-06 13:20:00 UTC (rev 4481)
@@ -369,18 +369,21 @@
 #define JUMPLISTREG_OK 0
 #define sfree free
 
-static OSVERSIONINFO osVersion;
 static char *IniFile = NULL;
 
-BOOL init_winver(void)
+BOOL isJumpListSupported(void)
 {
-    ZeroMemory(&osVersion, sizeof(osVersion));
-    osVersion.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
-//    return GetVersionEx ( (OSVERSIONINFO *) &osVersion);
+	static OSVERSIONINFO osVersion;
 
-	osVersion.dwMajorVersion = 7;
-	osVersion.dwMinorVersion = 0;
-	return 0;
+	if (osVersion.dwOSVersionInfoSize != sizeof(OSVERSIONINFO)) {
+ 		osVersion.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+		GetVersionEx(&osVersion);
+	}
+	if ((osVersion.dwMajorVersion < 6) ||
+	    (osVersion.dwMajorVersion == 6 && osVersion.dwMinorVersion < 1))
+		return FALSE;
+	else
+		return TRUE;
 }
 
 int add_to_jumplist_registry(const char *item)
@@ -665,13 +668,10 @@
 /* Adds a saved session to the Windows 7 jumplist. */
 void add_session_to_jumplist(const char * const sessionname, char *inifile)
 {
-	init_winver();
-
-    if ((osVersion.dwMajorVersion < 6) ||
-        (osVersion.dwMajorVersion == 6 && osVersion.dwMinorVersion < 1))
+    if (!isJumpListSupported())
         return;                        /* do nothing on pre-Win7 systems */
 
-	IniFile = inifile;
+    IniFile = inifile;
 
     if (add_to_jumplist_registry(sessionname) == JUMPLISTREG_OK) {
         update_jumplist_from_registry();
@@ -684,8 +684,7 @@
 /* Removes a saved session from the Windows jumplist. */
 void remove_session_from_jumplist(const char * const sessionname)
 {
-    if ((osVersion.dwMajorVersion < 6) ||
-        (osVersion.dwMajorVersion == 6 && osVersion.dwMinorVersion < 1))
+    if (!isJumpListSupported())
         return;                        /* do nothing on pre-Win7 systems */
 
     if (remove_from_jumplist_registry(sessionname) == JUMPLISTREG_OK) {



Ttssh2-commit メーリングリストの案内