8# include <KnownFolders.h>
11# include <propvarutil.h>
12# include <shlobj_core.h>
52 LPWSTR quick_launch_folder_path;
53 if (SHGetKnownFolderPath(
54 FOLDERID_ImplicitAppShortcuts, KF_FLAG_DEFAULT,
NULL, &quick_launch_folder_path) != S_OK)
59 std::wstring search_path = quick_launch_folder_path;
60 CoTaskMemFree(quick_launch_folder_path);
62 for (
auto const &dir_entry : std::filesystem::recursive_directory_iterator(search_path)) {
64 Microsoft::WRL::ComPtr<IShellLinkW> shell_link;
65 if (CoCreateInstance(__uuidof(ShellLink),
NULL, CLSCTX_ALL, IID_PPV_ARGS(&shell_link)) != S_OK)
70 Microsoft::WRL::ComPtr<IPersistFile> persist_file;
71 if (shell_link.As(&persist_file) != S_OK) {
75 if (persist_file->Load(dir_entry.path().c_str(), STGM_READWRITE) != S_OK) {
79 Microsoft::WRL::ComPtr<IPropertyStore> property_store;
80 if (shell_link.As(&property_store) != S_OK) {
85 PROPVARIANT app_model;
86 PropVariantInit(&app_model);
87 if (property_store->GetValue(PKEY_AppUserModel_ID, &app_model) == S_OK) {
88 if (app_model.vt == VT_LPWSTR && std::wstring(BLENDER_WIN_APPID_16) == app_model.pwszVal) {
89 shell_link->SetPath(launcher_path_w);
90 persist_file->Save(
NULL, TRUE);
93 PropVariantClear(&app_model);
Compatibility-like things for windows.
bool BLI_windows_update_pinned_launcher(const char *launcher_path)
COM helper functions for windows.
int conv_utf_8_to_16(const char *in8, wchar_t *out16, size_t size16)
#define UTF16_ENCODE(in8str)
#define UTF16_UN_ENCODE(in8str)