• R/O
  • SSH
  • HTTPS

ttssh2: Commit


Commit MetaInfo

Revision5208 (tree)
Time2013-04-20 19:05:27
Author(del#1144)

Log Message

iphlpapi.dll, user32.dll を遅延読み込みに変更

GetMonitorInfo が Windows95 にないため
r5161 の修正を再修正

Change Summary

Incremental Difference

--- trunk/teraterm/ttpmacro/ttl.c (revision 5207)
+++ trunk/teraterm/ttpmacro/ttl.c (revision 5208)
@@ -39,6 +39,7 @@
3939 #include <winsock2.h>
4040 #include <ws2tcpip.h>
4141 #include <iptypes.h>
42+#include <iphlpapi.h>
4243
4344 #define TTERMCOMMAND "TTERMPRO /D="
4445 #define CYGTERMCOMMAND "cyglaunch -o /D="
@@ -2330,23 +2331,16 @@
23302331 }
23312332
23322333
2333-typedef DWORD (__stdcall *pGetAdaptersAddresses)(ULONG Family,
2334- DWORD Flags,
2335- PVOID Reserved,
2336- PIP_ADAPTER_ADDRESSES pAdapterAddresses,
2337- PULONG pOutBufLen);
2338-
23392334 WORD TTLGetIPv6Addr()
23402335 {
23412336 WORD Err;
23422337 TVarId VarId, VarId2, id;
23432338 int num, result, arysize;
2344- DWORD ret;
2345- IP_ADAPTER_ADDRESSES addr[256];/* XXX */
2346- ULONG len = sizeof(addr);
2339+ DWORD ret;
2340+ IP_ADAPTER_ADDRESSES addr[256];/* XXX */
2341+ ULONG len = sizeof(addr);
23472342 char ipv6str[64];
2348- HMODULE h;
2349- pGetAdaptersAddresses pfunc;
2343+ OSVERSIONINFO osvi;
23502344
23512345 Err = 0;
23522346 GetStrAryVar(&VarId,&Err);
@@ -2355,22 +2349,22 @@
23552349 Err = ErrSyntax;
23562350 if (Err!=0) return Err;
23572351
2358- // 自分自身の全IPv6アドレスを取得する。
2359- if ((h = LoadLibrary("iphlpapi.dll")) == NULL) {
2352+ // IPv6 がサポートされていない OS はここで return
2353+ osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
2354+ GetVersionEx(&osvi);
2355+ if ( osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ||
2356+ (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT && osvi.dwMajorVersion == 4) ) {
2357+ // 9x, NT4.0 は IPv6 非対応
23602358 SetResult(-1);
23612359 SetIntVal(VarId2, 0);
23622360 return Err;
23632361 }
2364- if ((pfunc = (pGetAdaptersAddresses)GetProcAddress(h, "GetAdaptersAddresses")) == NULL) {
2365- FreeLibrary(h);
2366- SetResult(-1);
2367- SetIntVal(VarId2, 0);
2368- return Err;
2369- }
2362+
2363+ // 自分自身の全IPv6アドレスを取得する。
23702364 arysize = GetStrAryVarSize(VarId);
23712365 num = 0;
23722366 result = 1;
2373- ret = pfunc(AF_INET6, 0, NULL, addr, &len);
2367+ ret = GetAdaptersAddresses(AF_INET6, 0, NULL, addr, &len);
23742368 if (ret == ERROR_SUCCESS) {
23752369 IP_ADAPTER_ADDRESSES *padap = &addr[0];
23762370
@@ -2406,7 +2400,6 @@
24062400 SetResult(result);
24072401 SetIntVal(VarId2, num);
24082402
2409- FreeLibrary(h);
24102403 return Err;
24112404 }
24122405
Show on old repository browser