diff --git a/repertory/repertory/src/ui/mgmt_app_config.cpp b/repertory/repertory/src/ui/mgmt_app_config.cpp index 2ae41e5d..b15553a5 100644 --- a/repertory/repertory/src/ui/mgmt_app_config.cpp +++ b/repertory/repertory/src/ui/mgmt_app_config.cpp @@ -247,6 +247,7 @@ void mgmt_app_config::set_auto_start(bool auto_start) { utils::shortcut_cfg cfg{}; cfg.arguments = {L"-ui", L"-lo"}; cfg.exe_path = utils::path::combine(L".", {L"repertory"}); + cfg.icon_path = utils::path::combine(".", {"icon.ico"}); cfg.location = utils::path::absolute(L"."); cfg.shortcut_name = L"repertory"; if (utils::create_shortcut(cfg, false)) { diff --git a/support/include/utils/windows.hpp b/support/include/utils/windows.hpp index 86e43463..2cc95865 100644 --- a/support/include/utils/windows.hpp +++ b/support/include/utils/windows.hpp @@ -45,6 +45,7 @@ void free_console(); struct shortcut_cfg final { std::wstring arguments; std::wstring exe_path; + std::wstring icon_path; std::wstring location{get_startup_folder()}; std::wstring shortcut_name; std::wstring working_directory; diff --git a/support/src/utils/windows.cpp b/support/src/utils/windows.cpp index 5cd2747e..577dd63e 100644 --- a/support/src/utils/windows.cpp +++ b/support/src/utils/windows.cpp @@ -242,6 +242,17 @@ auto create_shortcut(const shortcut_cfg &cfg, bool overwrite_existing) -> bool { return false; } + if (not cfg.icon_path.empty()) { + result = psl->SetIconLocation(cfg.icon_path.c_str(), 0); + if (FAILED(result)) { + utils::error::handle_error( + function_name, + std::string("IShellLink::SetIconLocation failed: ") + hr_hex(result)); + psl->Release(); + return false; + } + } + if (not utils::file::file{lnk_path}.remove()) { utils::error::handle_error(function_name, "failed to remove existing shortcut|path|" +