Tera Termの個人的な作業用リポジトリ
リビジョン | ad1e59f95aa3605efecdb7039417534608b4ff6c (tree) |
---|---|
日時 | 2019-12-14 00:13:21 |
作者 | zmatsuo <zmatsuo@user...> |
コミッター | zmatsuo |
openDirectoryWithExplorer() の引数を char * から wchar_t * に変更
- プロジェクト内から mbstowcs() がなくなった
git-svn-id: svn+ssh://svn.osdn.net/svnroot/ttssh2/branches/unicode_buf@8444 f5f01b69-1e22-0410-acbf-894ab4bd6246
@@ -5163,38 +5163,29 @@ error:; | ||
5163 | 5163 | // return TRUE: success |
5164 | 5164 | // FALSE: failure |
5165 | 5165 | // |
5166 | -static BOOL openDirectoryWithExplorer(char *path) | |
5166 | +static BOOL openDirectoryWithExplorer(const wchar_t *path) | |
5167 | 5167 | { |
5168 | 5168 | LPSHELLFOLDER pDesktopFolder; |
5169 | 5169 | LPMALLOC pMalloc; |
5170 | 5170 | LPITEMIDLIST pIDL; |
5171 | - WCHAR pwszDisplayName[1024]; | |
5172 | - size_t szRet, DisplayNameMax; | |
5173 | 5171 | SHELLEXECUTEINFO si; |
5174 | 5172 | BOOL ret = FALSE; |
5175 | 5173 | |
5176 | - DisplayNameMax = sizeof(pwszDisplayName) / sizeof(pwszDisplayName[0]); | |
5177 | - | |
5178 | 5174 | if (SHGetDesktopFolder(&pDesktopFolder) == S_OK) { |
5179 | 5175 | if (SHGetMalloc(&pMalloc) == S_OK) { |
5180 | - szRet = mbstowcs(pwszDisplayName, path, DisplayNameMax - 1); | |
5181 | - if (szRet != -1) { | |
5182 | - pwszDisplayName[szRet] = L'\0'; | |
5183 | - | |
5184 | - if (pDesktopFolder->ParseDisplayName(NULL, NULL, pwszDisplayName, NULL, &pIDL, NULL) == S_OK) { | |
5185 | - ::ZeroMemory(&si, sizeof(si)); | |
5186 | - si.cbSize = sizeof(si); | |
5187 | - si.fMask = SEE_MASK_IDLIST; | |
5188 | - si.lpVerb = _T("open"); | |
5189 | - si.lpIDList = pIDL; | |
5190 | - si.nShow = SW_SHOWNORMAL; | |
5191 | - ::ShellExecuteEx(&si); | |
5192 | - pMalloc->Free((void*)pIDL); | |
5193 | - | |
5194 | - ret = TRUE; | |
5195 | - } | |
5196 | - | |
5176 | + if (pDesktopFolder->ParseDisplayName(NULL, NULL, (LPWSTR)path, NULL, &pIDL, NULL) == S_OK) { | |
5177 | + ::ZeroMemory(&si, sizeof(si)); | |
5178 | + si.cbSize = sizeof(si); | |
5179 | + si.fMask = SEE_MASK_IDLIST; | |
5180 | + si.lpVerb = _T("open"); | |
5181 | + si.lpIDList = pIDL; | |
5182 | + si.nShow = SW_SHOWNORMAL; | |
5183 | + ::ShellExecuteEx(&si); | |
5184 | + pMalloc->Free((void *)pIDL); | |
5185 | + | |
5186 | + ret = TRUE; | |
5197 | 5187 | } |
5188 | + | |
5198 | 5189 | pMalloc->Release(); |
5199 | 5190 | } |
5200 | 5191 | pDesktopFolder->Release(); |
@@ -5203,14 +5194,15 @@ static BOOL openDirectoryWithExplorer(char *path) | ||
5203 | 5194 | return (ret); |
5204 | 5195 | } |
5205 | 5196 | |
5206 | - | |
5207 | 5197 | // |
5208 | 5198 | // フォルダもしくはファイルを開く。 |
5209 | 5199 | // |
5210 | 5200 | static void openFileDirectory(char *path, char *filename, BOOL open_directory_only, char *open_editor) |
5211 | 5201 | { |
5212 | 5202 | if (open_directory_only) { |
5213 | - openDirectoryWithExplorer(path); | |
5203 | + wchar_t *pathW = ToWcharA(path); | |
5204 | + openDirectoryWithExplorer(pathW); | |
5205 | + free(pathW); | |
5214 | 5206 | } |
5215 | 5207 | else { |
5216 | 5208 | openFileWithApplication(path, filename, open_editor); |