Revision: 8842 https://osdn.net/projects/ttssh2/scm/svn/commits/8842 Author: zmatsuo Date: 2020-07-06 22:54:17 +0900 (Mon, 06 Jul 2020) Log Message: ----------- _GetModuleFileNameW() 追加 Modified Paths: -------------- trunk/teraterm/common/compat_win.cpp trunk/teraterm/common/compat_win.h trunk/teraterm/common/layer_for_unicode.cpp trunk/teraterm/common/layer_for_unicode.h -------------- next part -------------- Modified: trunk/teraterm/common/compat_win.cpp =================================================================== --- trunk/teraterm/common/compat_win.cpp 2020-07-06 13:54:06 UTC (rev 8841) +++ trunk/teraterm/common/compat_win.cpp 2020-07-06 13:54:17 UTC (rev 8842) @@ -96,6 +96,7 @@ BOOL (WINAPI *pRemoveDirectoryW)(LPCWSTR lpPathName); DWORD (WINAPI *pGetFullPathNameW)(LPCWSTR lpFileName, DWORD nBufferLength, LPWSTR lpBuffer, LPWSTR *lpFilePart); HMODULE (WINAPI *pLoadLibraryW)(LPCWSTR lpLibFileName); +DWORD (WINAPI *pGetModuleFileNameW)(HMODULE hModule, LPWSTR lpFilename, DWORD nSize); // gdi32 int (WINAPI *pAddFontResourceExW)(LPCWSTR name, DWORD fl, PVOID res); @@ -249,6 +250,7 @@ { "RemoveDirectoryW", (void **)&pRemoveDirectoryW }, { "GetFullPathNameW", (void **)&pGetFullPathNameW }, { "LoadLibraryW", (void **)&pLoadLibraryW }, + { "GetModuleFileNameW", (void **)&pGetModuleFileNameW }, #endif { "GetConsoleWindow", (void **)&pGetConsoleWindow }, {}, @@ -344,6 +346,7 @@ pFindFirstFileW = NULL; pFindNextFileW = NULL; pRemoveDirectoryW = NULL; + pGetModuleFileNameW = NULL; } // GetConsoleWindow\x93\xC1\x95ʏ\x88\x97\x9D Modified: trunk/teraterm/common/compat_win.h =================================================================== --- trunk/teraterm/common/compat_win.h 2020-07-06 13:54:06 UTC (rev 8841) +++ trunk/teraterm/common/compat_win.h 2020-07-06 13:54:17 UTC (rev 8842) @@ -156,6 +156,7 @@ extern BOOL (WINAPI *pRemoveDirectoryW)(LPCWSTR lpPathName); extern DWORD (WINAPI *pGetFullPathNameW)(LPCWSTR lpFileName, DWORD nBufferLength, LPWSTR lpBuffer, LPWSTR *lpFilePart); extern HMODULE (WINAPI *pLoadLibraryW)(LPCWSTR lpLibFileName); +extern DWORD (WINAPI *pGetModuleFileNameW)(HMODULE hModule, LPWSTR lpFilename, DWORD nSize); // shlobj_core.h extern LPITEMIDLIST (WINAPI *pSHBrowseForFolderW)(LPBROWSEINFOW lpbi); Modified: trunk/teraterm/common/layer_for_unicode.cpp =================================================================== --- trunk/teraterm/common/layer_for_unicode.cpp 2020-07-06 13:54:06 UTC (rev 8841) +++ trunk/teraterm/common/layer_for_unicode.cpp 2020-07-06 13:54:17 UTC (rev 8842) @@ -837,3 +837,18 @@ free(LibFileNameA); return r; } + +DWORD _GetModuleFileNameW(HMODULE hModule, LPWSTR lpFilename, DWORD nSize) +{ + if (pGetModuleFileNameW != NULL) { + return pGetModuleFileNameW(hModule, lpFilename, nSize); + } + + char filenameA[MAX_PATH]; + DWORD r = GetModuleFileNameA(hModule, filenameA, sizeof(filenameA)); + wchar_t *bufW = ToWcharA(filenameA); + wcsncpy_s(lpFilename, nSize, bufW, _TRUNCATE); + r = (DWORD)wcslen(lpFilename); + free(bufW); + return r; +} Modified: trunk/teraterm/common/layer_for_unicode.h =================================================================== --- trunk/teraterm/common/layer_for_unicode.h 2020-07-06 13:54:06 UTC (rev 8841) +++ trunk/teraterm/common/layer_for_unicode.h 2020-07-06 13:54:17 UTC (rev 8842) @@ -136,6 +136,7 @@ BOOL _RemoveDirectoryW(LPCWSTR lpPathName); DWORD _GetFullPathNameW(LPCWSTR lpFileName, DWORD nBufferLength, LPWSTR lpBuffer, LPWSTR *lpFilePart); HMODULE _LoadLibraryW(LPCWSTR lpLibFileName); +DWORD _GetModuleFileNameW(HMODULE hModule, LPWSTR lpFilename, DWORD nSize); // gdi32.lib int _AddFontResourceW(LPCWSTR lpFileName);