From 99b50713ce8e5a26412d4c1f084cc04713e855d0 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Mon, 8 Sep 2025 13:27:16 -0500 Subject: [PATCH] try to fix 3 --- support/src/utils/file_directory.cpp | 3 +++ support/src/utils/windows.cpp | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/support/src/utils/file_directory.cpp b/support/src/utils/file_directory.cpp index 39eba052..9b5601be 100644 --- a/support/src/utils/file_directory.cpp +++ b/support/src/utils/file_directory.cpp @@ -21,6 +21,7 @@ */ #include "utils/file_directory.hpp" +#include "utils/com_init_wrapper.hpp" #include "utils/common.hpp" #include "utils/error.hpp" #include "utils/string.hpp" @@ -172,6 +173,8 @@ auto directory::create_directory(std::string_view path) const } #if defined(_WIN32) + [[maybe_unused]] static const utils::com_init_wrapper wrapper; + auto res = ::SHCreateDirectory(nullptr, utils::string::from_utf8(abs_path).c_str()); if (res != ERROR_SUCCESS) { diff --git a/support/src/utils/windows.cpp b/support/src/utils/windows.cpp index aafcb0e8..c5cbd1cd 100644 --- a/support/src/utils/windows.cpp +++ b/support/src/utils/windows.cpp @@ -23,6 +23,7 @@ #include "utils/windows.hpp" +#include "utils/com_init_wrapper.hpp" #include "utils/error.hpp" #include "utils/file.hpp" #include "utils/path.hpp" @@ -65,6 +66,8 @@ auto get_last_error_code() -> DWORD { return ::GetLastError(); } auto get_local_app_data_directory() -> const std::string & { REPERTORY_USES_FUNCTION_NAME(); + [[maybe_unused]] static const utils::com_init_wrapper wrapper; + static std::string app_data = ([]() -> std::string { PWSTR local_app_data{}; if (SUCCEEDED(::SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, nullptr, @@ -142,6 +145,8 @@ auto run_process_elevated(std::vector args) -> int { void set_last_error_code(DWORD error_code) { ::SetLastError(error_code); } auto get_startup_folder() -> std::wstring { + [[maybe_unused]] static const utils::com_init_wrapper wrapper; + PWSTR raw{nullptr}; auto result = ::SHGetKnownFolderPath(FOLDERID_Startup, 0, nullptr, &raw); if (FAILED(result)) { @@ -160,6 +165,8 @@ auto get_startup_folder() -> std::wstring { auto create_shortcut(const shortcut_cfg &cfg, bool overwrite_existing) -> bool { REPERTORY_USES_FUNCTION_NAME(); + [[maybe_unused]] static const utils::com_init_wrapper wrapper; + const auto hr_hex = [](HRESULT result) -> std::string { std::ostringstream oss; oss << "0x" << std::uppercase << std::hex << std::setw(8)