Revision: 10371 https://osdn.net/projects/ttssh2/scm/svn/commits/10371 Author: zmatsuo Date: 2022-11-20 01:34:34 +0900 (Sun, 20 Nov 2022) Log Message: ----------- アイコンをセットするようにした - r10265 Revision Links: -------------- https://osdn.net/projects/ttssh2/scm/svn/commits/10265 Modified Paths: -------------- trunk/tools/ttreg/CMakeLists.txt trunk/tools/ttreg/ttreg.cpp -------------- next part -------------- Modified: trunk/tools/ttreg/CMakeLists.txt =================================================================== --- trunk/tools/ttreg/CMakeLists.txt 2022-11-19 16:34:23 UTC (rev 10370) +++ trunk/tools/ttreg/CMakeLists.txt 2022-11-19 16:34:34 UTC (rev 10371) @@ -29,3 +29,7 @@ TARGETS ${PACKAGE_NAME} DESTINATION . ) +install(FILES + README.md + DESTINATION . + RENAME ttreg.md) Modified: trunk/tools/ttreg/ttreg.cpp =================================================================== --- trunk/tools/ttreg/ttreg.cpp 2022-11-19 16:34:23 UTC (rev 10370) +++ trunk/tools/ttreg/ttreg.cpp 2022-11-19 16:34:34 UTC (rev 10371) @@ -55,7 +55,7 @@ * \x83V\x83\x87\x81[\x83g\x83J\x83b\x83g\x82\xF0\x8D\xEC\x82\xE9 * Win32 API */ -HRESULT CreateShortcut(const wchar_t *exe, const wchar_t *args, const wchar_t *dest) +HRESULT CreateShortcut(const wchar_t *exe, const wchar_t *args, const wchar_t *dest, const wchar_t *icon_path, int icon_no) { HRESULT hres; @@ -69,8 +69,11 @@ if (args != NULL) { hres = psl->SetArguments(args); } - //hres = psl->SetDescription(desc); + if (icon_path != NULL) { + psl->SetIconLocation(icon_path, icon_no); + } + // save IPersistFile* ppf; hres = psl->QueryInterface(IID_IPersistFile, (LPVOID*)&ppf); @@ -88,12 +91,12 @@ /** * \x83V\x83\x87\x81[\x83g\x83J\x83b\x83g\x82\xF0\x8D\xEC\x82\xE9 */ -void CreateShortcut(const wchar_t *dir, const wchar_t *shortcut, const wchar_t *teraterm, const wchar_t *args) +void CreateShortcut(const wchar_t *dir, const wchar_t *shortcut, const wchar_t *teraterm, const wchar_t *args, const wchar_t *icon_path = NULL, int icon_no = 0) { wchar_t shortcut_full[MAX_PATH]; swprintf(shortcut_full, _countof(shortcut_full), L"%s\\%s", dir, shortcut); wchar_t *escaped_command = EscapeCommand(teraterm); - CreateShortcut(escaped_command, args, shortcut_full); + CreateShortcut(escaped_command, args, shortcut_full, icon_path, icon_no); free(escaped_command); } @@ -100,7 +103,7 @@ /** * \x83\x8C\x83W\x83X\x83g\x83\x8A\x82\xF0\x8F\x91\x82\xAB\x8Fo\x82\xB7 */ -void WriteReg(FILE *fp, const wchar_t *menu, const wchar_t *key, const wchar_t *command, const wchar_t *arg) +void WriteReg(FILE *fp, const wchar_t *menu, const wchar_t *key, const wchar_t *command, const wchar_t *arg, const wchar_t *icon = NULL) { wchar_t *escaped_command = EscapeCommand(command); wchar_t *escaped_arg = EscapeCommand(arg); @@ -107,11 +110,13 @@ fwprintf(fp, L"[HKEY_CURRENT_USER\\SOFTWARE\\Classes\\Folder\\shell\\%s]\n" L"@=\"%s\"\n" + L"\"Icon\"=\"%s\"\n" L"\n" L"[HKEY_CURRENT_USER\\SOFTWARE\\Classes\\Folder\\shell\\%s\\command]\n" L"@=\"%s %s\"\n\n", key, menu, + icon == NULL ? L"" : icon, key, escaped_command, escaped_arg); free(escaped_arg); @@ -191,59 +196,78 @@ CreateShortcut(shortcut_dir, L"Tera Term.lnk", teraterm_full, NULL); if (cygwin_installed) { - CreateShortcut(shortcut_dir, L"Tera Term + cmd.lnk", cyglaunch_full, L"-cygwin -s \"c:/windows/system32/cmd.exe\""); + CreateShortcut(shortcut_dir, L"Tera Term + cmd.lnk", cyglaunch_full, L"-cygwin -s \"c:/windows/system32/cmd.exe\"", + L"c:\\windows\\system32\\cmd.exe", 0); WriteReg(fp, L"Tera Term + cmd Here", L"cygterm_cmd", cyglaunch_full, - L"-nocd -v CHERE_INVOKING=y -d \"\\\"%L\\\"\" -s \"c:/windows/system32/cmd.exe\""); + L"-nocd -v CHERE_INVOKING=y -d \"\\\"%L\\\"\" -s \"c:/windows/system32/cmd.exe\"", + L"c:\\windows\\system32\\cmd.exe"); - CreateShortcut(shortcut_dir, L"Tera Term + powershell.lnk", cyglaunch_full, L"-cygwin -s \"c:/Windows/System32/WindowsPowerShell/v1.0/powershell.exe\""); - CreateShortcut(shortcut_dir, L"Tera Term + wsl.lnk", cyglaunch_full, L"-cygwin -s \"c:/windows/system32/wsl.exe\""); + CreateShortcut(shortcut_dir, L"Tera Term + powershell.lnk", cyglaunch_full, L"-cygwin -s \"c:/Windows/System32/WindowsPowerShell/v1.0/powershell.exe\"", + L"c:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", 0); + CreateShortcut(shortcut_dir, L"Tera Term + wsl.lnk", cyglaunch_full, L"-cygwin -s \"c:/windows/system32/wsl.exe\"", + L"c:\\windows\\system32\\wsl.exe", 0); } if (cygwin_installed) { - CreateShortcut(shortcut_dir, L"Tera Term + Cygwin.lnk", cyglaunch_full, L"-cygwin"); + //static const wchar_t *cygwin_icon = L"C:\\cygwin64\\Cygwin.ico"; + static const wchar_t *cygwin_icon = cyglaunch_full; + CreateShortcut(shortcut_dir, L"Tera Term + Cygwin.lnk", cyglaunch_full, L"-cygwin", + cygwin_icon, 0); + WriteReg(fp, L"Tera Term + Cygwin Here", L"cygterm", cyglaunch_full, - L"-nocd -v CHERE_INVOKING=y -d \"\\\"%L\\\"\""); + L"-nocd -v CHERE_INVOKING=y -d \"\\\"%L\\\"\"", + cygwin_icon); } if (msys2tarm && msys2_installed) { - CreateShortcut(shortcut_dir, L"Tera Term + MSYS2 MSYS.lnk", cyglaunch_full, L"-msys2 -v MSYSTEM=MSYS"); - CreateShortcut(shortcut_dir, L"Tera Term + MSYS2 MinGW x32.lnk", cyglaunch_full, L"-msys2 -v MSYSTEM=MINGW32"); - CreateShortcut(shortcut_dir, L"Tera Term + MSYS2 MinGW x64.lnk", cyglaunch_full, L"-msys2 -v MSYSTEM=MINGW64"); + static const wchar_t *msys2_icon = L"c:\\msys64\\msys2.ico"; + static const wchar_t *mingw32_icon = L"c:\\msys64\\mingw32.ico"; + static const wchar_t *mingw64_icon = L"c:\\msys64\\mingw64.ico"; + CreateShortcut(shortcut_dir, L"Tera Term + MSYS2 MSYS.lnk", cyglaunch_full, L"-msys2 -v MSYSTEM=MSYS", msys2_icon, 0); + CreateShortcut(shortcut_dir, L"Tera Term + MSYS2 MinGW x32.lnk", cyglaunch_full, L"-msys2 -v MSYSTEM=MINGW32", mingw32_icon, 0); + CreateShortcut(shortcut_dir, L"Tera Term + MSYS2 MinGW x64.lnk", cyglaunch_full, L"-msys2 -v MSYSTEM=MINGW64", mingw64_icon, 0); + WriteReg(fp, L"Tera Term + MSYS2 MSYS Here", L"msys2term_msys", cyglaunch_full, - L"-msys2 -nocd -v CHERE_INVOKING=y -d \"\\\"%L\\\"\" -v MSYSTEM=MSYS"); + L"-msys2 -nocd -v CHERE_INVOKING=y -d \"\\\"%L\\\"\" -v MSYSTEM=MSYS", + msys2_icon); WriteReg(fp, L"Tera Term + MSYS2 MinGW x32 Here", L"msys2term_mingw32", cyglaunch_full, - L"-msys2 -nocd -v CHERE_INVOKING=y -d \"\\\"%L\\\"\" -v MSYSTEM=MINGW32"); + L"-msys2 -nocd -v CHERE_INVOKING=y -d \"\\\"%L\\\"\" -v MSYSTEM=MINGW32", + mingw32_icon); WriteReg(fp, L"Tera Term + MSYS2 MinGW x64 Here", L"msys2term_mingw64", cyglaunch_full, - L"-msys2 -nocd -v CHERE_INVOKING=y -d \"\\\"%L\\\"\" -v MSYSTEM=MINGW64"); + L"-msys2 -nocd -v CHERE_INVOKING=y -d \"\\\"%L\\\"\" -v MSYSTEM=MINGW64", + mingw64_icon); } if (gitbash_installed) { - CreateShortcut(shortcut_dir, L"Tera Term + git_bash.lnk", cyglaunch_full, L"-gitbash"); + static const wchar_t *git_bash_icon = L"C:\\Program Files\\Git\\git-bash.exe"; + CreateShortcut(shortcut_dir, L"Tera Term + git_bash.lnk", cyglaunch_full, L"-gitbash", git_bash_icon, 0); + WriteReg(fp, L"Tera Term + Git Bash Here", L"gitbash", cyglaunch_full, - L"-gitbash -nocd -v CHERE_INVOKING=y -d \"\\\"%L\\\"\""); + L"-gitbash -nocd -v CHERE_INVOKING=y -d \"\\\"%L\\\"\"", + git_bash_icon); } fclose(fp);