[Ttssh2-commit] [5208] iphlpapi.dll, user32. dll を遅延読み込みに変更

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2013年 4月 20日 (土) 19:05:27 JST


Revision: 5208
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/5208
Author:   maya
Date:     2013-04-20 19:05:27 +0900 (Sat, 20 Apr 2013)
Log Message:
-----------
iphlpapi.dll, user32.dll を遅延読み込みに変更
  GetMonitorInfo が Windows95 にないため
  r5161 の修正を再修正

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

Modified Paths:
--------------
    trunk/teraterm/ttpmacro/ttl.c
    trunk/teraterm/ttpmacro/ttpmacro.vcproj

-------------- next part --------------
Modified: trunk/teraterm/ttpmacro/ttl.c
===================================================================
--- trunk/teraterm/ttpmacro/ttl.c	2013-04-19 15:41:37 UTC (rev 5207)
+++ trunk/teraterm/ttpmacro/ttl.c	2013-04-20 10:05:27 UTC (rev 5208)
@@ -39,6 +39,7 @@
 #include <winsock2.h>
 #include <ws2tcpip.h>
 #include <iptypes.h>
+#include <iphlpapi.h>
 
 #define TTERMCOMMAND "TTERMPRO /D="
 #define CYGTERMCOMMAND "cyglaunch -o /D="
@@ -2330,23 +2331,16 @@
 }
 
 
-typedef DWORD (__stdcall *pGetAdaptersAddresses)(ULONG Family,
-                                                 DWORD Flags,
-                                                 PVOID Reserved,
-                                                 PIP_ADAPTER_ADDRESSES pAdapterAddresses,
-                                                 PULONG pOutBufLen);
-
 WORD TTLGetIPv6Addr()
 {
 	WORD Err;
 	TVarId VarId, VarId2, id;
 	int num, result, arysize;
-    DWORD ret;
-    IP_ADAPTER_ADDRESSES addr[256];/* XXX */
-    ULONG len = sizeof(addr);
+	DWORD ret;
+	IP_ADAPTER_ADDRESSES addr[256];/* XXX */
+	ULONG len = sizeof(addr);
 	char ipv6str[64];
-	HMODULE h;
-	pGetAdaptersAddresses pfunc;
+	OSVERSIONINFO osvi;
 
 	Err = 0;
 	GetStrAryVar(&VarId,&Err);
@@ -2355,22 +2349,22 @@
 		Err = ErrSyntax;
 	if (Err!=0) return Err;
 
-	// \x8E\xA9\x95\xAA\x8E\xA9\x90g\x82̑SIPv6\x83A\x83h\x83\x8C\x83X\x82\xF0\x8E擾\x82\xB7\x82\xE9\x81B
-	if ((h = LoadLibrary("iphlpapi.dll")) == NULL) {
+	// IPv6 \x82\xAA\x83T\x83|\x81[\x83g\x82\xB3\x82\xEA\x82Ă\xA2\x82Ȃ\xA2 OS \x82͂\xB1\x82\xB1\x82\xC5 return
+	osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+	GetVersionEx(&osvi);
+	if ( osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ||
+	     (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT && osvi.dwMajorVersion == 4) ) {
+		// 9x, NT4.0 \x82\xCD IPv6 \x94\xF1\x91Ή\x9E
 		SetResult(-1);
 		SetIntVal(VarId2, 0);
 		return Err;
 	}
-	if ((pfunc = (pGetAdaptersAddresses)GetProcAddress(h, "GetAdaptersAddresses")) == NULL) {
-		FreeLibrary(h);
-		SetResult(-1);
-		SetIntVal(VarId2, 0);
-		return Err;
-	}
+
+	// \x8E\xA9\x95\xAA\x8E\xA9\x90g\x82̑SIPv6\x83A\x83h\x83\x8C\x83X\x82\xF0\x8E擾\x82\xB7\x82\xE9\x81B
 	arysize = GetStrAryVarSize(VarId);
 	num = 0;
 	result = 1;
-	ret = pfunc(AF_INET6, 0, NULL, addr, &len);
+	ret = GetAdaptersAddresses(AF_INET6, 0, NULL, addr, &len);
 	if (ret == ERROR_SUCCESS) {
 		IP_ADAPTER_ADDRESSES *padap = &addr[0];
 
@@ -2406,7 +2400,6 @@
 	SetResult(result);
 	SetIntVal(VarId2, num);
 
-	FreeLibrary(h);
 	return Err;
 }
 

Modified: trunk/teraterm/ttpmacro/ttpmacro.vcproj
===================================================================
--- trunk/teraterm/ttpmacro/ttpmacro.vcproj	2013-04-19 15:41:37 UTC (rev 5207)
+++ trunk/teraterm/ttpmacro/ttpmacro.vcproj	2013-04-20 10:05:27 UTC (rev 5208)
@@ -79,11 +79,12 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="onig_s.lib Version.lib"
+				AdditionalDependencies="onig_s.lib Version.lib iphlpapi.lib"
 				OutputFile="..\Release/ttpmacro.exe"
 				LinkIncremental="1"
 				SuppressStartupBanner="true"
 				AdditionalLibraryDirectories="..\..\libs\oniguruma;..\release"
+				DelayLoadDLLs="iphlpapi.dll;user32.dll"
 				GenerateDebugInformation="true"
 				ProgramDatabaseFile="..\Release/ttpmacro.pdb"
 				SubSystem="2"
@@ -176,11 +177,12 @@
 			/>
 			<Tool
 				Name="VCLinkerTool"
-				AdditionalDependencies="onig_sd.lib Version.lib"
+				AdditionalDependencies="onig_sd.lib Version.lib iphlpapi.lib"
 				OutputFile="..\Debug/ttpmacro.exe"
 				LinkIncremental="1"
 				SuppressStartupBanner="true"
 				AdditionalLibraryDirectories="..\..\libs\oniguruma;..\debug"
+				DelayLoadDLLs="iphlpapi.dll;user32.dll"
 				GenerateDebugInformation="true"
 				ProgramDatabaseFile="..\Debug/ttpmacro.pdb"
 				SubSystem="2"



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