在inno-setup中设置ToastActivator CLSID快捷方式属性

时间:2019-09-05 09:38:27

标签: inno-setup

我正在尝试为Win32应用程序启用Windows 10吐司通知。根据win docs(https://docs.microsoft.com/en-us/windows/uwp/design/shell/tiles-and-notifications/send-local-toast-desktop-cpp-wrl),我需要在开始菜单中创建一个设置了aumi-id和activator-clsid属性的快捷方式。 Win docs示例使用WiX安装程序。有什么办法可以在inno-setup中设置这些属性?

我尝试了inno和Windows COM组件的pascal脚本功能。我设法设置了aumi-id,但未设置activator-clsid。

我被困在重新创建必须作为参数传递给IPropertyStore COM接口的winApi结构和联合。

C code - this struct must be passed into the IPropertyStore method SetValue()
   struct tagPROPVARIANT {
       VARTYPE vt;
       PROPVAR_PAD1 wReserved1;
       PROPVAR_PAD2 wReserved2;
       PROPVAR_PAD3 wReserved3;
       union {
       .
       .
       CLSID *puuid;
       .
       .
       }
    }
-
Inno Pascal script - declaration of IPropertyStore interface and recreation of tagPROPVARIANT
    [code]
    type
        IPropertyStore = interface(IUnknown)
            procedure dummy;
            procedure dummy2;
            procedure dummy3;
            function SetValue(var key: PROPERTYKEY; var pv: tagPROPVARIANT): HResult;
            procedure dummy4;
        end;
        tagPROPVARIANT = record
            vt: WORD;
            res1: WORD;
            res2: WORD;
            res3: WORD;
            // now somehow recreate union with 72 members where I only need one pointer (CLSID *puuid)
        end;
        // then I use IShellLink, IPropertyStore, IPersistFile
        // interfaces to create shortcut in the start menu, where IPropertyStore must be used to set properties that I need.
        // I managed to recreate IShellLink and IPersistFile because they do not use unions nor pointers

我能够创建开始菜单快捷方式,并按以下方式设置其AUMI:

[Icons]
Name: "{group}\{#APP_NAME}"; Filename: "{app}\{#EXE_NAME}"; AppUserModelID: "MyCompany.MyApp"

但是我认为只能使用COM Iterfaces在[代码]部分中设置CLSID。

基本上,我正在尝试将此c ++代码重写为inno-setup脚本,以使内容更简洁。

    ComPtr<IShellLinkW> shellLink;
    CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&shellLink));
    shellLink->SetPath(exePath);
    shellLink->SetArguments(L"");
    shellLink->SetWorkingDirectory(exePath);

    ComPtr<IPropertyStore> propertyStore;
    shellLink.As(&propertyStore);
    tagPROPVARIANT appIdPropVar;
    InitPropVariantFromString(L"MyComp.MyApp", &appIdPropVar);
    propertyStore->SetValue(PKEY_AppUserModel_ID, appIdPropVar);

    // main problem
    GUID clsid = __uuidof(NotificationActivator); 
    tagPROPVARIANT CLSIDofMyToastHandler;
    CLSIDofMyToastHandler.vt = VT_CLSID;
    CLSIDofMyToastHandler.puuid = &clsid;

    propertyStore->SetValue(PKEY_AppUserModel_ToastActivatorCLSID, CLSIDofMyToastHandler)
    propertyStore->Commit();

    ComPtr<IPersistFile> persistFile;
    shellLink.As(&persistFile);
    persistFile->Save(startMenuPath, TRUE);
    PropVariantClear(&appIdPropVar);

1 个答案:

答案 0 :(得分:1)

Inno Setup 6.1现在可以通过指定AppUserModelToastActivatorCLSID parameter in the Icons section来设置CLSID。