Revision: 9617 https://osdn.net/projects/ttssh2/scm/svn/commits/9617 Author: zmatsuo Date: 2021-12-23 22:18:57 +0900 (Thu, 23 Dec 2021) Log Message: ----------- hExpandEnvironmentStringsW() 追加 Modified Paths: -------------- trunk/teraterm/common/win32helper.cpp trunk/teraterm/common/win32helper.h -------------- next part -------------- Modified: trunk/teraterm/common/win32helper.cpp =================================================================== --- trunk/teraterm/common/win32helper.cpp 2021-12-23 13:18:48 UTC (rev 9616) +++ trunk/teraterm/common/win32helper.cpp 2021-12-23 13:18:57 UTC (rev 9617) @@ -242,3 +242,16 @@ HWND hWnd = GetDlgItem(hDlg, id); return hGetWindowTextW(hWnd, text); } + +DWORD hExpandEnvironmentStringsW(const wchar_t *src, wchar_t **expanded) +{ + size_t len = (size_t)ExpandEnvironmentStringsW(src, NULL, 0); + wchar_t *dest = (wchar_t *)malloc(sizeof(wchar_t) * len); + if (dest == NULL) { + *expanded = NULL; + return ERROR_NOT_ENOUGH_MEMORY; + } + ExpandEnvironmentStringsW(src, dest, (DWORD)len); + *expanded = dest; + return NO_ERROR; +} Modified: trunk/teraterm/common/win32helper.h =================================================================== --- trunk/teraterm/common/win32helper.h 2021-12-23 13:18:48 UTC (rev 9616) +++ trunk/teraterm/common/win32helper.h 2021-12-23 13:18:57 UTC (rev 9617) @@ -40,6 +40,7 @@ DWORD hGetCurrentDirectoryW(wchar_t **dir); DWORD hGetWindowTextW(HWND hWnd, wchar_t **text); DWORD hGetDlgItemTextW(HWND hDlg, int id, wchar_t **text); +DWORD hExpandEnvironmentStringsW(const wchar_t *src, wchar_t **expanded); #ifdef __cplusplus }