[Ttssh2-commit] [6852] マクロコマンド getver のバージョン取得方法を変更。

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2017年 7月 7日 (金) 22:23:34 JST


Revision: 6852
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/6852
Author:   doda
Date:     2017-07-07 22:23:34 +0900 (Fri, 07 Jul 2017)
Log Message:
-----------
マクロコマンド getver のバージョン取得方法を変更。

ttermpro.exe のバージョン情報を参照していたのを変更し、
tt-version.h のマクロを直接利用するようにした。

そもそも r6793 で getver が壊れていたが、この修正で直る。
SetDefaultDllDirectories() が GetFileVersionInfo() に影響を与えるなんて聞いて無いよ~
実は MSDN の英語版の GetFileVersionInfo() には情報があるけど。

https://msdn.microsoft.com/en-us/library/windows/desktop/ms647003.aspx
| If a full path is not specified, the function uses the search sequence specified by the LoadLibrary function.

他に LoadLibrary() の検索パスを利用する API って無いよな……

Revision Links:
--------------
    http://sourceforge.jp/projects/ttssh2/scm/svn/commits/6793

Modified Paths:
--------------
    trunk/teraterm/ttpmacro/ttl.c
    trunk/teraterm/ttpmacro/ttpmacro.v10.vcxproj
    trunk/teraterm/ttpmacro/ttpmacro.v11.vcxproj
    trunk/teraterm/ttpmacro/ttpmacro.v12.vcxproj
    trunk/teraterm/ttpmacro/ttpmacro.v14.vcxproj
    trunk/teraterm/ttpmacro/ttpmacro.v15.vcxproj
    trunk/teraterm/ttpmacro/ttpmacro.v9.vcproj
    trunk/teraterm/ttpmacro/ttpmacro.vcproj

-------------- next part --------------
Modified: trunk/teraterm/ttpmacro/ttl.c
===================================================================
--- trunk/teraterm/ttpmacro/ttl.c	2017-07-06 22:22:16 UTC (rev 6851)
+++ trunk/teraterm/ttpmacro/ttl.c	2017-07-07 13:23:34 UTC (rev 6852)
@@ -36,6 +36,7 @@
 #include <mbstring.h>
 #include <time.h>
 #include <errno.h>
+#include "tt-version.h"
 #include "ttmdlg.h"
 #include "ttmbuff.h"
 #include "ttmparse.h"
@@ -2798,87 +2799,29 @@
 	return Err;
 }
 
-// \x8E\xC0\x8Ds\x83t\x83@\x83C\x83\x8B\x82\xA9\x82\xE7\x83o\x81[\x83W\x83\x87\x83\x93\x8F\xEE\x95\xF1\x82𓾂\xE9 (2005.2.28 yutaka)
-static void get_file_version(char *exefile, int *major, int *minor, int *release, int *build)
-{
-	typedef struct {
-		WORD wLanguage;
-		WORD wCodePage;
-	} LANGANDCODEPAGE, *LPLANGANDCODEPAGE;
-	LPLANGANDCODEPAGE lplgcode;
-	UINT unLen;
-	DWORD size;
-	char *buf = NULL;
-	BOOL ret;
-	int i;
-	char fmt[80];
-	char *pbuf;
-
-	size = GetFileVersionInfoSize(exefile, NULL);
-	if (size == 0) {
-		goto error;
-	}
-	buf = malloc(size);
-	ZeroMemory(buf, size);
-
-	if (GetFileVersionInfo(exefile, 0, size, buf) == FALSE) {
-		goto error;
-	}
-
-	ret = VerQueryValue(buf,
-			"\\VarFileInfo\\Translation", 
-			(LPVOID *)&lplgcode, &unLen);
-	if (ret == FALSE)
-		goto error;
-
-	for (i = 0 ; i < (int)(unLen / sizeof(LANGANDCODEPAGE)) ; i++) {
-		_snprintf_s(fmt, sizeof(fmt), _TRUNCATE, "\\StringFileInfo\\%04x%04x\\FileVersion", 
-			lplgcode[i].wLanguage, lplgcode[i].wCodePage);
-		VerQueryValue(buf, fmt, &pbuf, &unLen);
-		if (unLen > 0) { // get success
-			int n, a, b, c, d;
-
-			n = sscanf(pbuf, "%d, %d, %d, %d", &a, &b, &c, &d);
-			if (n == 4) { // convert success
-				*major = a;
-				*minor = b;
-				*release = c;
-				*build = d;
-				break;
-			}
-		}
-	}
-
-	free(buf);
-	return;
-
-error:
-	free(buf);
-	*major = *minor = *release = *build = 0;
-}
-
 //
-// Tera Term\x82\xCCversion\x82\xF0\x8E擾\x82\xB7\x82\xE9
+// Tera Term \x82̃o\x81[\x83W\x83\x87\x83\x93\x8E擾 & \x94\xE4\x8Ar
+// \x83o\x81[\x83W\x83\x87\x83\x93\x94ԍ\x86\x82̓R\x83\x93\x83p\x83C\x83\x8B\x8E\x9E\x82Ɍ\x88\x92肷\x82\xE9\x81B
+// (\x8C\xBB\x8D݂͎\xC0\x8Ds\x83t\x83@\x83C\x83\x8B\x82̃o\x81[\x83W\x83\x87\x83\x93\x8F\xEE\x95\xF1\x82͎Q\x8FƂ\xB5\x82Ȃ\xA2)
 //
-// (2008.2.4 yutaka)
-//
 WORD TTLGetVer()
 {
 	TVarId VarId;
 	WORD Err;
 	TStrVal Str1, Str2;
-	int a, b, c, d;
+	int cur_major = TT_VERSION_MAJOR;
+	int cur_minor = TT_VERSION_MINOR;
 	int compare = 0;
-	int major, minor, ret;
-	int curver, ver;
+	int comp_major, comp_minor, ret;
+	int cur_ver, comp_ver;
 
 	Err = 0;
-	GetStrVar(&VarId,&Err);
+	GetStrVar(&VarId, &Err);
 
 	if (CheckParameterGiven()) {
 		GetStrVal(Str1, &Err);
 
-		ret = sscanf_s(Str1, "%d.%d", &major, &minor);
+		ret = sscanf_s(Str1, "%d.%d", &comp_major, &comp_minor);
 		if (ret != 2) {
 			SetResult(-2);
 			return 0;
@@ -2895,17 +2838,16 @@
 		Err = ErrSyntax;
 	if (Err!=0) return Err;
 
-	get_file_version("ttermpro.exe", &a, &b, &c, &d);
-	_snprintf_s(Str2, sizeof(Str2), _TRUNCATE, "%d.%d", a, b);
-	SetStrVal(VarId,Str2);
+	_snprintf_s(Str2, sizeof(Str2), _TRUNCATE, "%d.%d", cur_major, cur_minor);
+	SetStrVal(VarId, Str2);
 
 	if (compare == 1) {
-		curver = a * 100 + b;
-		ver = major * 100 + minor;
+		cur_ver = cur_major * 100 + cur_minor;
+		comp_ver = comp_major * 100 + comp_minor;
 
-		if (curver < ver) {
+		if (cur_ver < comp_ver) {
 			SetResult(-1);
-		} else if (curver == ver) {
+		} else if (cur_ver == comp_ver) {
 			SetResult(0);
 		} else {
 			SetResult(1);

Modified: trunk/teraterm/ttpmacro/ttpmacro.v10.vcxproj
===================================================================
--- trunk/teraterm/ttpmacro/ttpmacro.v10.vcxproj	2017-07-06 22:22:16 UTC (rev 6851)
+++ trunk/teraterm/ttpmacro/ttpmacro.v10.vcxproj	2017-07-07 13:23:34 UTC (rev 6852)
@@ -78,7 +78,7 @@
       <AdditionalIncludeDirectories>$(SolutionDir)common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ResourceCompile>
     <Link>
-      <AdditionalDependencies>onig_s.lib;SFMT.lib;Version.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>onig_s.lib;SFMT.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <SuppressStartupBanner>true</SuppressStartupBanner>
       <AdditionalLibraryDirectories>$(SolutionDir)..\libs\oniguruma\src;$(SolutionDir)..\libs\SFMT;$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <DelayLoadDLLs>iphlpapi.dll;user32.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
@@ -114,7 +114,7 @@
       <AdditionalIncludeDirectories>$(SolutionDir)common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ResourceCompile>
     <Link>
-      <AdditionalDependencies>onig_sd.lib;SFMTd.lib;Version.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>onig_sd.lib;SFMTd.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <SuppressStartupBanner>true</SuppressStartupBanner>
       <AdditionalLibraryDirectories>$(SolutionDir)..\libs\oniguruma\src;$(SolutionDir)..\libs\SFMT;$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <DelayLoadDLLs>iphlpapi.dll;user32.dll;%(DelayLoadDLLs)</DelayLoadDLLs>

Modified: trunk/teraterm/ttpmacro/ttpmacro.v11.vcxproj
===================================================================
--- trunk/teraterm/ttpmacro/ttpmacro.v11.vcxproj	2017-07-06 22:22:16 UTC (rev 6851)
+++ trunk/teraterm/ttpmacro/ttpmacro.v11.vcxproj	2017-07-07 13:23:34 UTC (rev 6852)
@@ -79,7 +79,7 @@
       <AdditionalIncludeDirectories>$(SolutionDir)common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ResourceCompile>
     <Link>
-      <AdditionalDependencies>onig_s.lib;SFMT.lib;Version.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>onig_s.lib;SFMT.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <SuppressStartupBanner>true</SuppressStartupBanner>
       <AdditionalLibraryDirectories>$(SolutionDir)..\libs\oniguruma\src;$(SolutionDir)..\libs\SFMT;$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <DelayLoadDLLs>iphlpapi.dll;user32.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
@@ -114,7 +114,7 @@
       <AdditionalIncludeDirectories>$(SolutionDir)common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ResourceCompile>
     <Link>
-      <AdditionalDependencies>onig_sd.lib;SFMTd.lib;Version.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>onig_sd.lib;SFMTd.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <SuppressStartupBanner>true</SuppressStartupBanner>
       <AdditionalLibraryDirectories>$(SolutionDir)..\libs\oniguruma\src;$(SolutionDir)..\libs\SFMT;$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <DelayLoadDLLs>iphlpapi.dll;user32.dll;%(DelayLoadDLLs)</DelayLoadDLLs>

Modified: trunk/teraterm/ttpmacro/ttpmacro.v12.vcxproj
===================================================================
--- trunk/teraterm/ttpmacro/ttpmacro.v12.vcxproj	2017-07-06 22:22:16 UTC (rev 6851)
+++ trunk/teraterm/ttpmacro/ttpmacro.v12.vcxproj	2017-07-07 13:23:34 UTC (rev 6852)
@@ -79,7 +79,7 @@
       <AdditionalIncludeDirectories>$(SolutionDir)common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ResourceCompile>
     <Link>
-      <AdditionalDependencies>nafxcw.lib;LIBCMT.lib;onig_s.lib;SFMT.lib;Version.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>nafxcw.lib;LIBCMT.lib;onig_s.lib;SFMT.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <SuppressStartupBanner>true</SuppressStartupBanner>
       <AdditionalLibraryDirectories>$(SolutionDir)..\libs\oniguruma\src;$(SolutionDir)..\libs\SFMT;$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <DelayLoadDLLs>iphlpapi.dll;user32.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
@@ -115,7 +115,7 @@
       <AdditionalIncludeDirectories>$(SolutionDir)common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ResourceCompile>
     <Link>
-      <AdditionalDependencies>nafxcwd.lib;LIBCMTD.lib;onig_sd.lib;SFMTd.lib;Version.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>nafxcwd.lib;LIBCMTD.lib;onig_sd.lib;SFMTd.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <SuppressStartupBanner>true</SuppressStartupBanner>
       <AdditionalLibraryDirectories>$(SolutionDir)..\libs\oniguruma\src;$(SolutionDir)..\libs\SFMT;$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <DelayLoadDLLs>iphlpapi.dll;user32.dll;%(DelayLoadDLLs)</DelayLoadDLLs>

Modified: trunk/teraterm/ttpmacro/ttpmacro.v14.vcxproj
===================================================================
--- trunk/teraterm/ttpmacro/ttpmacro.v14.vcxproj	2017-07-06 22:22:16 UTC (rev 6851)
+++ trunk/teraterm/ttpmacro/ttpmacro.v14.vcxproj	2017-07-07 13:23:34 UTC (rev 6852)
@@ -79,7 +79,7 @@
       <AdditionalIncludeDirectories>$(SolutionDir)common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ResourceCompile>
     <Link>
-      <AdditionalDependencies>nafxcw.lib;LIBCMT.lib;onig_s.lib;SFMT.lib;Version.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>nafxcw.lib;LIBCMT.lib;onig_s.lib;SFMT.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <SuppressStartupBanner>true</SuppressStartupBanner>
       <AdditionalLibraryDirectories>$(SolutionDir)..\libs\oniguruma\src;$(SolutionDir)..\libs\SFMT;$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <DelayLoadDLLs>iphlpapi.dll;user32.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
@@ -115,7 +115,7 @@
       <AdditionalIncludeDirectories>$(SolutionDir)common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ResourceCompile>
     <Link>
-      <AdditionalDependencies>nafxcwd.lib;LIBCMTD.lib;onig_sd.lib;SFMTd.lib;Version.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>nafxcwd.lib;LIBCMTD.lib;onig_sd.lib;SFMTd.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <SuppressStartupBanner>true</SuppressStartupBanner>
       <AdditionalLibraryDirectories>$(SolutionDir)..\libs\oniguruma\src;$(SolutionDir)..\libs\SFMT;$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <DelayLoadDLLs>iphlpapi.dll;user32.dll;%(DelayLoadDLLs)</DelayLoadDLLs>

Modified: trunk/teraterm/ttpmacro/ttpmacro.v15.vcxproj
===================================================================
--- trunk/teraterm/ttpmacro/ttpmacro.v15.vcxproj	2017-07-06 22:22:16 UTC (rev 6851)
+++ trunk/teraterm/ttpmacro/ttpmacro.v15.vcxproj	2017-07-07 13:23:34 UTC (rev 6852)
@@ -80,7 +80,7 @@
       <AdditionalIncludeDirectories>$(SolutionDir)common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ResourceCompile>
     <Link>
-      <AdditionalDependencies>nafxcw.lib;LIBCMT.lib;onig_s.lib;SFMT.lib;Version.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>nafxcw.lib;LIBCMT.lib;onig_s.lib;SFMT.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <SuppressStartupBanner>true</SuppressStartupBanner>
       <AdditionalLibraryDirectories>$(SolutionDir)..\libs\oniguruma\src;$(SolutionDir)..\libs\SFMT;$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <DelayLoadDLLs>iphlpapi.dll;user32.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
@@ -116,7 +116,7 @@
       <AdditionalIncludeDirectories>$(SolutionDir)common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
     </ResourceCompile>
     <Link>
-      <AdditionalDependencies>nafxcwd.lib;LIBCMTD.lib;onig_sd.lib;SFMTd.lib;Version.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>nafxcwd.lib;LIBCMTD.lib;onig_sd.lib;SFMTd.lib;iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <SuppressStartupBanner>true</SuppressStartupBanner>
       <AdditionalLibraryDirectories>$(SolutionDir)..\libs\oniguruma\src;$(SolutionDir)..\libs\SFMT;$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <DelayLoadDLLs>iphlpapi.dll;user32.dll;%(DelayLoadDLLs)</DelayLoadDLLs>

Modified: trunk/teraterm/ttpmacro/ttpmacro.v9.vcproj
===================================================================
--- trunk/teraterm/ttpmacro/ttpmacro.v9.vcproj	2017-07-06 22:22:16 UTC (rev 6851)
+++ trunk/teraterm/ttpmacro/ttpmacro.v9.vcproj	2017-07-07 13:23:34 UTC (rev 6852)
@@ -73,7 +73,7 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="onig_s.lib SFMT.lib Version.lib iphlpapi.lib"
+				AdditionalDependencies="onig_s.lib SFMT.lib iphlpapi.lib"
 				LinkIncremental="1"
 				SuppressStartupBanner="true"
 				AdditionalLibraryDirectories="$(SolutionDir)..\libs\oniguruma\src;$(SolutionDir)..\libs\SFMT;$(OutDir)"
@@ -161,7 +161,7 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="onig_sd.lib SFMTd.lib Version.lib iphlpapi.lib"
+				AdditionalDependencies="onig_sd.lib SFMTd.lib iphlpapi.lib"
 				LinkIncremental="1"
 				SuppressStartupBanner="true"
 				AdditionalLibraryDirectories="$(SolutionDir)..\libs\oniguruma\src;$(SolutionDir)..\libs\SFMT;$(OutDir)"

Modified: trunk/teraterm/ttpmacro/ttpmacro.vcproj
===================================================================
--- trunk/teraterm/ttpmacro/ttpmacro.vcproj	2017-07-06 22:22:16 UTC (rev 6851)
+++ trunk/teraterm/ttpmacro/ttpmacro.vcproj	2017-07-07 13:23:34 UTC (rev 6852)
@@ -72,7 +72,7 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="onig_s.lib SFMT.lib Version.lib iphlpapi.lib"
+				AdditionalDependencies="onig_s.lib SFMT.lib iphlpapi.lib"
 				LinkIncremental="1"
 				SuppressStartupBanner="true"
 				AdditionalLibraryDirectories="$(SolutionDir)..\libs\oniguruma\src;$(SolutionDir)..\libs\SFMT;$(OutDir)"
@@ -161,7 +161,7 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="onig_sd.lib SFMTd.lib Version.lib iphlpapi.lib"
+				AdditionalDependencies="onig_sd.lib SFMTd.lib iphlpapi.lib"
 				LinkIncremental="1"
 				SuppressStartupBanner="true"
 				AdditionalLibraryDirectories="$(SolutionDir)..\libs\oniguruma\src;$(SolutionDir)..\libs\SFMT;$(OutDir)"



Ttssh2-commit メーリングリストの案内
Back to archive index