svnno****@sourc*****
svnno****@sourc*****
2015年 3月 1日 (日) 23:54:51 JST
Revision: 5810 http://sourceforge.jp/projects/ttssh2/scm/svn/commits/5810 Author: yutakapon Date: 2015-03-01 23:54:49 +0900 (Sun, 01 Mar 2015) Log Message: ----------- チケット #34943 設定フォルダを開く Virtual Store対応。 まだ実装中なので、以前と動作は変わりません。 Ticket Links: ------------ http://sourceforge.jp/projects/ttssh2/tracker/detail/34943 Modified Paths: -------------- trunk/teraterm/teraterm/vtwin.cpp -------------- next part -------------- Modified: trunk/teraterm/teraterm/vtwin.cpp =================================================================== --- trunk/teraterm/teraterm/vtwin.cpp 2015-02-28 16:35:58 UTC (rev 5809) +++ trunk/teraterm/teraterm/vtwin.cpp 2015-03-01 14:54:49 UTC (rev 5810) @@ -4575,6 +4575,91 @@ // +// Virtual Store\x82\xF0\x8AJ\x82\xAD\x81B +// +// return TRUE: success +// FALSE: failure +// +static BOOL openVirtualStore(char *path, int pathlen) +{ + BOOL ret = FALSE; + char *s, **p; + char *virstore_env[] = { + "ProgramFiles", + "ProgramData", + "SystemRoot", + NULL + }; + char shPath[1024] = ""; + LPITEMIDLIST pidl; + int CSIDL; + OSVERSIONINFO osvi; + HANDLE hToken; + DWORD dwLength; + TOKEN_ELEVATION tokenElevation; + + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + GetVersionEx(&osvi); + // Windows Vista\x88ȑO\x82͖\xB3\x8E\x8B\x82\xB7\x82\xE9\x81B + if (!(osvi.dwPlatformId == VER_PLATFORM_WIN32_NT && osvi.dwMajorVersion >= 6)) + goto error; + + // TODO: UAC\x82\xAA\x97L\x8C\xF8\x82\xA9\x82ǂ\xA4\x82\xA9\x81B + // HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\x82\xCCEnableLUA(DWORD\x92l)\x82\xAA0\x82\xA9\x82ǂ\xA4\x82\xA9\x82Ŕ\xBB\x92f\x82ł\xAB\x82܂\xB7(0\x82\xCDUAC\x96\xB3\x8C\xF8\x81A1\x82\xCDUAC\x97L\x8C\xF8)\x81B + + // UAC\x82\xAA\x97L\x8C\xF8\x8E\x9E\x81A\x83v\x83\x8D\x83Z\x83X\x82\xAA\x8AǗ\x9D\x8EҌ\xA0\x8C\xC0\x82ɏ\xB8\x8Ai\x82\xB5\x82Ă\xA2\x82邩\x81B + if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY | TOKEN_ADJUST_DEFAULT, &hToken)) { + if (GetTokenInformation(hToken, TokenElevation, &tokenElevation, sizeof(TOKEN_ELEVATION), &dwLength)) { + // (0\x82͏\xB8\x8Ai\x82\xB5\x82Ă\xA2\x82Ȃ\xA2\x81A\x94\xF10\x82͏\xB8\x8Ai\x82\xB5\x82Ă\xA2\x82\xE9)\x81B + if (tokenElevation.TokenIsElevated != 0) { + // \x8AǗ\x9D\x8EҌ\xA0\x8C\xC0\x82\xF0\x8E\x9D\x82\xC1\x82Ă\xA2\x82\xE9\x82̂ł\xA0\x82\xEA\x82AVirtual Store\x82͓\xAD\x82\xA9\x82Ȃ\xA2\x81B + CloseHandle(hToken); + goto error; + } + } + CloseHandle(hToken); + } + + // Virtual Store\x91ΏۂƂȂ\xE9\x83t\x83H\x83\x8B\x83_\x82\xA9\x81B + p = virstore_env; + while (*p) { + s = getenv(*p); + if (s != NULL && strstr(path, s) != NULL) { + break; + } + p++; + } + if (*p == NULL) + goto error; + + CSIDL = CSIDL_LOCAL_APPDATA; + if (SHGetSpecialFolderLocation(NULL, CSIDL, &pidl) != S_OK) { + goto error; + } + SHGetPathFromIDList(pidl, shPath); + CoTaskMemFree(pidl); + + // Virtual Store\x83p\x83X\x82\xF0\x8D\xEC\x82\xE9\x81B + strncat_s(shPath, sizeof(shPath), "\\VirtualStore", _TRUNCATE); + + // \x95s\x97v\x82ȃh\x83\x89\x83C\x83u\x83\x8C\x83^\x81[\x82\xF0\x8F\x9C\x8B\x8E\x82\xB7\x82\xE9\x81B + // \x83h\x83\x89\x83C\x83u\x83\x8C\x83^\x81[\x82͈ꕶ\x8E\x9A\x82Ƃ͌\xC0\x82\xE7\x82Ȃ\xA2\x93_\x82ɒ\x8D\x88ӁB + s = strstr(path, ":\\"); + if (s != NULL) { + strncat_s(shPath, sizeof(shPath), s+1, _TRUNCATE); + } + openDirectoryWithExplorer(shPath, sizeof(shPath)); + + ret = TRUE; + return (ret); + +error: + openDirectoryWithExplorer(path, sizeof(path)); + + return (ret); +} + +// // \x8C\xBB\x8Dݓǂݍ\x9E\x82܂\xEA\x82Ă\xA2\x82\xE9 teraterm.ini \x83t\x83@\x83C\x83\x8B\x82\xAA\x8Ai\x94[\x82\xB3\x82\xEA\x82Ă\xA2\x82\xE9 // \x83t\x83H\x83\x8B\x83_\x82\xF0\x83G\x83N\x83X\x83v\x83\x8D\x81[\x83\x89\x82ŊJ\x82\xAD\x81B // @@ -4582,12 +4667,30 @@ // void CVTWindow::OnOpenSetupDirectory() { - char path[MAX_PATH]; + char path[MAX_PATH], inipath[MAX_PATH]; +// char Temp[MAX_PATH]; - // \x90ݒ\xE8\x83t\x83@\x83C\x83\x8B\x82̃p\x83X\x82\xF0\x8E擾\x82\xB7\x82\xE9\x81B - ExtractDirName(ts.SetupFName, path); + // \x90ݒ\xE8\x83t\x83@\x83C\x83\x8B(teraterm.ini)\x82̃p\x83X\x82\xF0\x8E擾\x82\xB7\x82\xE9\x81B + ExtractDirName(ts.SetupFName, inipath); + openDirectoryWithExplorer(inipath, sizeof(inipath)); + //openVirtualStore(inipath, sizeof(inipath)); - openDirectoryWithExplorer(path, sizeof(path)); +#if 0 + // cygterm.cfg + if (GetModuleFileName(NULL, Temp, sizeof(Temp)) != 0) { + ExtractDirName(Temp, path); + // teraterm.ini\x82ƈقȂ\xE9\x83p\x83X\x82̏ꍇ\x81A\x90V\x82\xB5\x82\xAD\x8AJ\x82\xAD\x81B + if (strcmp(inipath, path) != 0) { + openVirtualStore(path, sizeof(path)); + } + } + + // KEYBOARD.CNF + //ExtractDirName(ts.KeyCnfFN, path); + //openDirectoryWithExplorer(path, sizeof(path)); + + // ssh_known_hosts +#endif }