• R/O
  • SSH
  • HTTPS

ttssh2: Commit


Commit MetaInfo

Revision5161 (tree)
Time2013-03-23 06:03:32
Author(del#1144)

Log Message

Windows 2000 以前で ttpmacro.exe を実行するとエラーになるのを修正

GetAdaptersAddresses を見つけられないエラーになるので iphlpapi.dll を LoadLibrary する

Change Summary

Incremental Difference

--- trunk/teraterm/ttpmacro/ttl.c (revision 5160)
+++ trunk/teraterm/ttpmacro/ttl.c (revision 5161)
@@ -43,7 +43,6 @@
4343 #include <winsock2.h>
4444 #include <ws2tcpip.h>
4545 #include <iptypes.h>
46-#include <iphlpapi.h>
4746
4847 #define TTERMCOMMAND "TTERMPRO /D="
4948 #define CYGTERMCOMMAND "cyglaunch -o /D="
@@ -2247,6 +2246,12 @@
22472246 }
22482247
22492248
2249+typedef DWORD (__stdcall *pGetAdaptersAddresses)(ULONG Family,
2250+ DWORD Flags,
2251+ PVOID Reserved,
2252+ PIP_ADAPTER_ADDRESSES pAdapterAddresses,
2253+ PULONG pOutBufLen);
2254+
22502255 WORD TTLGetIPv6Addr()
22512256 {
22522257 WORD Err;
@@ -2256,6 +2261,8 @@
22562261 IP_ADAPTER_ADDRESSES addr[256];/* XXX */
22572262 ULONG len = sizeof(addr);
22582263 char ipv6str[64];
2264+ HMODULE h;
2265+ pGetAdaptersAddresses pfunc;
22592266
22602267 Err = 0;
22612268 GetStrVar(&VarId,&Err);
@@ -2264,8 +2271,18 @@
22642271 if (Err!=0) return Err;
22652272
22662273 // 自分自身の全IPv6アドレスを取得する。
2274+ if ((h = LoadLibrary("iphlpapi.dll")) == NULL) {
2275+ int err = GetLastError();
2276+ SetResult(-1);
2277+ return Err;
2278+ }
2279+ if ((pfunc = (pGetAdaptersAddresses)GetProcAddress(h, "GetAdaptersAddresses")) == NULL) {
2280+ FreeLibrary(h);
2281+ SetResult(-1);
2282+ return Err;
2283+ }
22672284 num = 0;
2268- ret = GetAdaptersAddresses(AF_INET6, 0, NULL, addr, &len);
2285+ ret = pfunc(AF_INET6, 0, NULL, addr, &len);
22692286 if (ret == ERROR_SUCCESS) {
22702287 IP_ADAPTER_ADDRESSES *padap = &addr[0];
22712288
@@ -2297,6 +2314,7 @@
22972314
22982315 SetResult(num);
22992316
2317+ FreeLibrary(h);
23002318 return Err;
23012319 }
23022320
Show on old repository browser