10# ifdef WIN32_LEAN_AND_MEAN
11# undef WIN32_LEAN_AND_MEAN
15# include <KnownFolders.h>
18# include <propvarutil.h>
19# include <shlobj_core.h>
61 LPWSTR quick_launch_folder_path;
62 if (SHGetKnownFolderPath(
63 FOLDERID_ImplicitAppShortcuts, KF_FLAG_DEFAULT,
nullptr, &quick_launch_folder_path) !=
69 std::wstring search_path = quick_launch_folder_path;
70 CoTaskMemFree(quick_launch_folder_path);
72 for (
auto const &dir_entry : std::filesystem::recursive_directory_iterator(search_path)) {
74 Microsoft::WRL::ComPtr<IShellLinkW> shell_link;
75 if (CoCreateInstance(__uuidof(ShellLink),
nullptr, CLSCTX_ALL, IID_PPV_ARGS(&shell_link)) !=
81 Microsoft::WRL::ComPtr<IPersistFile> persist_file;
82 if (shell_link.As(&persist_file) != S_OK) {
86 if (persist_file->Load(dir_entry.path().c_str(), STGM_READWRITE) != S_OK) {
90 Microsoft::WRL::ComPtr<IPropertyStore> property_store;
91 if (shell_link.As(&property_store) != S_OK) {
96 PROPVARIANT app_model;
97 PropVariantInit(&app_model);
98 if (property_store->GetValue(PKEY_AppUserModel_ID, &app_model) == S_OK) {
99 if (app_model.vt == VT_LPWSTR && std::wstring(BLENDER_WIN_APPID_16) == app_model.pwszVal) {
100 shell_link->SetPath(launcher_path_w);
101 persist_file->Save(
nullptr, TRUE);
104 PropVariantClear(&app_model);
Compatibility-like things for windows.
COM helper functions for windows.
bool BLI_windows_update_pinned_launcher(const char *launcher_path)
constexpr size_t ARRAY_SIZE(const T(&arg)[N]) noexcept
int conv_utf_8_to_16(const char *in8, wchar_t *out16, size_t size16)
#define UTF16_ENCODE(in8str)
#define UTF16_UN_ENCODE(in8str)