[ttssh2-commit] [9421] VirtualStoreのパス生成時 _SHGetKnownFolderPath() を使用するよう修正

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2021年 9月 19日 (日) 00:46:46 JST


Revision: 9421
          https://osdn.net/projects/ttssh2/scm/svn/commits/9421
Author:   zmatsuo
Date:     2021-09-19 00:46:46 +0900 (Sun, 19 Sep 2021)
Log Message:
-----------
VirtualStoreのパス生成時 _SHGetKnownFolderPath() を使用するよう修正

- 修正前は SHGetSpecialFolderLocation() を使用していた

Modified Paths:
--------------
    trunk/teraterm/teraterm/setupdirdlg.cpp

-------------- next part --------------
Modified: trunk/teraterm/teraterm/setupdirdlg.cpp
===================================================================
--- trunk/teraterm/teraterm/setupdirdlg.cpp	2021-09-13 15:20:06 UTC (rev 9420)
+++ trunk/teraterm/teraterm/setupdirdlg.cpp	2021-09-18 15:46:46 UTC (rev 9421)
@@ -265,10 +265,6 @@
 		L"SystemRoot",
 		NULL
 	};
-	LPITEMIDLIST pidl;
-	int CSIDL;
-	wchar_t shPath[1024];
-	wchar_t *vs_file;
 	const wchar_t** p = virstore_env;
 
 	if (GetVirtualStoreEnvironment() == FALSE)
@@ -285,15 +281,13 @@
 	if (*p == NULL)
 		goto error;
 
-	CSIDL = CSIDL_LOCAL_APPDATA;
-	if (SHGetSpecialFolderLocation(NULL, CSIDL, &pidl) != S_OK) {
-		goto error;
-	}
-	SHGetPathFromIDListW(pidl, shPath);
-	CoTaskMemFree(pidl);
 
 	// Virtual Store\x83p\x83X\x82\xF0\x8D\xEC\x82\xE9\x81B
-	aswprintf(&vs_file, L"%s\\VirtualStore%s", shPath, path_nodrive, file);
+	wchar_t *local_appdata;
+	_SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, NULL, &local_appdata);
+	wchar_t *vs_file;
+	aswprintf(&vs_file, L"%s\\VirtualStore%s", local_appdata, path_nodrive, file);
+	free(local_appdata);
 
 	// \x8DŌ\xE3\x82ɁAVirtual Store\x82Ƀt\x83@\x83C\x83\x8B\x82\xAA\x82\xA0\x82邩\x82ǂ\xA4\x82\xA9\x82𒲂ׂ\xE9\x81B
 	if (GetFileAttributesW(vs_file) == INVALID_FILE_ATTRIBUTES) {


ttssh2-commit メーリングリストの案内
Back to archive index