Parcourir la source

Added new [Icons] section parameter: AppUserModelToastActivatorCLSID.

Martijn Laan il y a 5 ans
Parent
commit
b068377acd

+ 2 - 1
Components/ScintStylerInnoSetup.pas

@@ -343,9 +343,10 @@ const
     (Name: 'StrongAssemblyName'),
     (Name: 'Tasks'));
 
-  IconsSectionParameters: array[0..17] of TInnoSetupStylerParamInfo = (
+  IconsSectionParameters: array[0..18] of TInnoSetupStylerParamInfo = (
     (Name: 'AfterInstall'),
     (Name: 'AppUserModelID'),
+    (Name: 'AppUserModelToastActivatorCLSID'),
     (Name: 'BeforeInstall'),
     (Name: 'Check'),
     (Name: 'Comment'),

+ 7 - 0
ISHelp/isetup.xml

@@ -1938,6 +1938,13 @@ Filename: "http://www.example.com/"
 </example>
 </param>
 
+<param name="AppUserModelToastActivatorCLSID">
+<p>Specifies the Windows 10 (or later) Application User Model Toast Activator CLSID for the shortcut. Ignored on earlier Windows versions.</p>
+<example>
+<pre>AppUserModelToastActivatorCLSID: "B784B1A4-D682-4FE6-BDBA-21EDDAE42795"</pre>
+</example>
+</param>
+
 <param name="Flags">
 <p>This parameter is a set of extra options. Multiple options may be used by separating them by spaces. The following options are supported:</p>
 

+ 13 - 7
Projects/Compile.pas

@@ -5187,8 +5187,8 @@ procedure TSetupCompiler.EnumIconsProc(const Line: PChar; const Ext: Integer);
 
 type
   TParam = (paFlags, paName, paFilename, paParameters, paWorkingDir, paHotKey,
-    paIconFilename, paIconIndex, paComment, paAppUserModelID, paComponents, paTasks,
-    paLanguages, paCheck, paBeforeInstall, paAfterInstall, paMinVersion,
+    paIconFilename, paIconIndex, paComment, paAppUserModelID, paAppUserModelToastActivatorCLSID,
+    paComponents, paTasks, paLanguages, paCheck, paBeforeInstall, paAfterInstall, paMinVersion,
     paOnlyBelowVersion);
 const
   ParamIconsName = 'Name';
@@ -5200,6 +5200,7 @@ const
   ParamIconsIconIndex = 'IconIndex';
   ParamIconsComment = 'Comment';
   ParamIconsAppUserModelID = 'AppUserModelID';
+  ParamIconsAppUserModelToastActivatorCLSID = 'AppUserModelToastActivatorCLSID';
   ParamInfo: array[TParam] of TParamInfo = (
     (Name: ParamCommonFlags; Flags: []),
     (Name: ParamIconsName; Flags: [piRequired, piNoEmpty, piNoQuotes]),
@@ -5211,6 +5212,7 @@ const
     (Name: ParamIconsIconIndex; Flags: []),
     (Name: ParamIconsComment; Flags: []),
     (Name: ParamIconsAppUserModelID; Flags: []),
+    (Name: ParamIconsAppUserModelToastActivatorCLSID; Flags: []),
     (Name: ParamCommonComponents; Flags: []),
     (Name: ParamCommonTasks; Flags: []),
     (Name: ParamCommonLanguages; Flags: []),
@@ -5291,8 +5293,13 @@ begin
       { Comment }
       Comment := Values[paComment].Data;
 
-      { AppUserModelID }
+      { AppUserModel }
       AppUserModelID := Values[paAppUserModelID].Data;
+      S := Values[paAppUserModelToastActivatorCLSID].Data;
+      if S <> '' then begin
+        AppUserModelToastActivatorCLSID := StringToGUID('{' + S + '}');
+        Include(Options, ioHasAppUserModelToastActivatorCLSID);
+      end;
 
       { Common parameters }
       ProcessExpressionParameter(ParamCommonComponents, Values[paComponents].Data, EvalComponentIdentifier, True, Components);
@@ -5312,13 +5319,12 @@ begin
       if (IconIndex <> 0) and (IconFilename = '') then
         IconFilename := Filename;
 
-      S := IconName;
-      if Copy(S, 1, 8) = '{group}\' then
-        Delete(S, 1, 8);
-
       CheckCheckOrInstall(ParamCommonCheck, Check, cikCheck);
       CheckCheckOrInstall(ParamCommonBeforeInstall, BeforeInstall, cikInstall);
       CheckCheckOrInstall(ParamCommonAfterInstall, AfterInstall, cikInstall);
+      S := IconName;
+      if Copy(S, 1, 8) = '{group}\' then
+        Delete(S, 1, 8);
       CheckConst(S, MinVersion, []);
       CheckConst(Filename, MinVersion, []);
       CheckConst(Parameters, MinVersion, []);

+ 28 - 3
Projects/InstFnc2.pas

@@ -16,6 +16,7 @@ interface
 function CreateShellLink(const Filename, Description, ShortcutTo, Parameters,
   WorkingDir: String; IconFilename: String; const IconIndex, ShowCmd: Integer;
   const HotKey: Word; FolderShortcut: Boolean; const AppUserModelID: String;
+  const AppUserModelToastActivatorCLSID: PGUID;
   const ExcludeFromShowInNewInstall, PreventPinning: Boolean): String;
 procedure RegisterTypeLibrary(const Filename: String);
 procedure UnregisterTypeLibrary(const Filename: String);
@@ -53,6 +54,12 @@ begin
   Result := (WindowsVersion >= Cardinal($06020000));
 end;
 
+function IsWindows10: Boolean;
+{ Returns True if running Windows 10 or later }
+begin
+  Result := (WindowsVersion >= Cardinal($0A000000));
+end;
+
 procedure AssignWorkingDir(const SL: IShellLink; const WorkingDir: String);
 { Assigns the specified working directory to SL. If WorkingDir is empty then
   we select one ourself as best we can. (Leaving the working directory field
@@ -156,6 +163,7 @@ type
 function CreateShellLink(const Filename, Description, ShortcutTo, Parameters,
   WorkingDir: String; IconFilename: String; const IconIndex, ShowCmd: Integer;
   const HotKey: Word; FolderShortcut: Boolean; const AppUserModelID: String;
+  const AppUserModelToastActivatorCLSID: PGUID;
   const ExcludeFromShowInNewInstall, PreventPinning: Boolean): String;
 { Creates a lnk file named Filename, with a description of Description, with a
   HotKey hotkey, which points to ShortcutTo. Filename should be a full path.
@@ -179,6 +187,9 @@ const
   PKEY_AppUserModel_StartPinOption: TPropertyKey = (
     fmtid: (D1:$9F4C2855; D2:$9F79; D3:$4B39; D4:($A8,$D0,$E1,$D4,$2D,$E1,$D5,$F3));
     pid: 12);
+  PKEY_AppUserModel_ToastActivatorCLSID: TPropertyKey = (
+    fmtid: (D1:$9F4C2855; D2:$9F79; D3:$4B39; D4:($A8,$D0,$E1,$D4,$2D,$E1,$D5,$F3));
+    pid: 26);
   APPUSERMODEL_STARTPINOPTION_NOPINONINSTALL = 1;
 
 {$IFNDEF Delphi3OrHigher}
@@ -231,7 +242,7 @@ begin
 
     { Note: Vista and newer support IPropertyStore but Vista errors if you try to
       commit a PKEY_AppUserModel_ID, so avoid setting the property on Vista. }
-    if IsWindows7 and ((AppUserModelID <> '') or ExcludeFromShowInNewInstall or PreventPinning) then begin
+    if IsWindows7 and ((AppUserModelID <> '') or (AppUserModelToastActivatorCLSID <> nil) or ExcludeFromShowInNewInstall or PreventPinning) then begin
       OleResult := SL.QueryInterface(IID_IPropertyStore, PS);
       if OleResult <> S_OK then
         RaiseOleError('IShellLink::QueryInterface(IID_IPropertyStore)', OleResult);
@@ -244,7 +255,7 @@ begin
         if OleResult <> S_OK then
           RaiseOleError('IPropertyStore::SetValue(PKEY_AppUserModel_PreventPinning)', OleResult);
       end;
-      if (AppUserModelID <> '') then begin
+      if AppUserModelID <> '' then begin
         PV.vt := VT_BSTR;
         PV.bstrVal := StringToOleStr(AppUserModelID);
         if PV.bstrVal = nil then
@@ -257,6 +268,13 @@ begin
           SysFreeString(PV.bstrVal);
         end;
       end;
+      if IsWindows10 and (AppUserModelToastActivatorCLSID <> nil) then begin
+        PV.vt := VT_CLSID;
+        PV.puuid := AppUserModelToastActivatorCLSID;
+        OleResult := PS.SetValue(PKEY_AppUserModel_ToastActivatorCLSID, PV);
+        if OleResult <> S_OK then
+          RaiseOleError('IPropertyStore::SetValue(PKEY_AppUserModel_ToastActivatorCLSID)', OleResult);
+      end;
       if ExcludeFromShowInNewInstall then begin
         PV.vt := VT_BOOL;
         Smallint(PV.vbool) := -1;
@@ -349,7 +367,7 @@ begin
 
   { Note: Vista and newer support IPropertyStore but Vista errors if you try to
     commit a PKEY_AppUserModel_ID, so avoid setting the property on Vista. }
-  if IsWindows7 and ((AppUserModelID <> '') or ExcludeFromShowInNewInstall or PreventPinning) then begin
+  if IsWindows7 and ((AppUserModelID <> '') or (AppUserModelToastActivatorCLSID <> nil) or ExcludeFromShowInNewInstall or PreventPinning) then begin
     PS := Obj as {$IFDEF IS_D14}PropSys.{$ENDIF}IPropertyStore;
     { According to MSDN the PreventPinning property should be set before the ID property. In practice
       this doesn't seem to matter - at least not for shortcuts - but do it first anyway. }
@@ -368,6 +386,13 @@ begin
       if OleResult <> S_OK then
         RaiseOleError('IPropertyStore::SetValue(PKEY_AppUserModel_ID)', OleResult);
     end;
+    if IsWindows10 and (AppUserModelToastActivatorCLSID <> nil) then begin
+      PV.vt := VT_CLSID;
+      PV.puuid := AppUserModelToastActivatorCLSID;
+      OleResult := PS.SetValue(PKEY_AppUserModel_ToastActivatorCLSID, PV);
+      if OleResult <> S_OK then
+        RaiseOleError('IPropertyStore::SetValue(PKEY_AppUserModel_ToastActivatorCLSID)', OleResult);
+    end;
     if ExcludeFromShowInNewInstall then begin
       PV.vt := VT_BOOL;
       PV.boolVal := True;

+ 12 - 7
Projects/Install.pas

@@ -2002,8 +2002,8 @@ var
       WorkingDir, IconFilename: String; const IconIndex, ShowCmd: Integer;
       const NeverUninstall: Boolean; const CloseOnExit: TSetupIconCloseOnExit;
       const HotKey: Word; FolderShortcut: Boolean;
-      const AppUserModelID: String; const ExcludeFromShowInNewInstall: Boolean;
-      const PreventPinning: Boolean);
+      const AppUserModelID: String; const AppUserModelToastActivatorCLSID: PGUID;
+      const ExcludeFromShowInNewInstall, PreventPinning: Boolean);
     var
       BeginsWithGroup: Boolean;
       LinkFilename, PifFilename, UrlFilename, DirFilename, ProbableFilename,
@@ -2059,8 +2059,8 @@ var
           environment-variable strings (e.g. %SystemRoot%\...) }
         ResultingFilename := CreateShellLink(LinkFilename, Description, Path,
           Parameters, WorkingDir, IconFilename, IconIndex, ShowCmd, HotKey,
-          FolderShortcut, AppUserModelID, ExcludeFromShowInNewInstall,
-          PreventPinning);
+          FolderShortcut, AppUserModelID, @AppUserModelToastActivatorCLSID,
+          ExcludeFromShowInNewInstall, PreventPinning);
         FolderShortcutCreated := FolderShortcut and DirExists(ResultingFilename);
 
         { If a .pif file was created, apply the "Close on exit" setting }
@@ -2135,6 +2135,7 @@ var
     CurIconNumber: Integer;
     CurIcon: PSetupIconEntry;
     FN: String;
+    TACLSID: PGUID;
   begin
     for CurIconNumber := 0 to Entries[seIcon].Count-1 do begin
       try
@@ -2147,15 +2148,19 @@ var
             FN := ExpandConst(Filename);
             if ioUseAppPaths in Options then
               FN := ExpandAppPath(FN);
-            if not(ioCreateOnlyIfFileExists in Options) or NewFileExistsRedir(IsWin64, FN) then
+            if not(ioCreateOnlyIfFileExists in Options) or NewFileExistsRedir(IsWin64, FN) then begin
+              if ioHasAppUserModelToastActivatorCLSID in Options then
+                TACLSID := @AppUserModelToastActivatorCLSID
+              else
+                TACLSID := nil;
               CreateAnIcon(IconName, ExpandConst(Comment), FN,
                 ExpandConst(Parameters), ExpandConst(WorkingDir),
                 ExpandConst(IconFilename), IconIndex, ShowCmd,
                 ioUninsNeverUninstall in Options, CloseOnExit, HotKey,
-                ioFolderShortcut in Options, ExpandConst(AppUserModelID),
+                ioFolderShortcut in Options, ExpandConst(AppUserModelID), TACLSID,
                 ioExcludeFromShowInNewInstall in Options,
                 ioPreventPinning in Options)
-            else
+            end else
               Log('Skipping due to "createonlyiffileexists" flag.');
 
             { Increment progress meter }

+ 1 - 1
Projects/ScriptFunc_R.pas

@@ -953,7 +953,7 @@ begin
       Stack.GetString(PStart-2), Stack.GetString(PStart-3),
       Stack.GetString(PStart-4), Stack.GetString(PStart-5),
       Stack.GetString(PStart-6), Stack.GetInt(PStart-7),
-      Stack.GetInt(PStart-8), 0, False, '', False, False));
+      Stack.GetInt(PStart-8), 0, False, '', nil, False, False));
   end else if Proc.Name = 'REGISTERTYPELIBRARY' then begin
     if Stack.GetBool(PStart) then
       HelperRegisterTypeLibrary(False, Stack.GetString(PStart-1))

+ 3 - 2
Projects/Struct.pas

@@ -33,7 +33,7 @@ const
     this file it's recommended you change SetupID. Any change will do (like
     changing the letters or numbers), as long as your format is
     unrecognizable by the standard Inno Setup. }
-  SetupID: TSetupID = 'Inno Setup Setup Data (6.0.0)'{$IFDEF UNICODE}+' (u)'{$ENDIF};
+  SetupID: TSetupID = 'Inno Setup Setup Data (6.1.0)'{$IFDEF UNICODE}+' (u)'{$ENDIF};
   UninstallLogID: array[Boolean] of TUninstallLogID =
     ('Inno Setup Uninstall Log (b)', 'Inno Setup Uninstall Log (b) 64-bit');
   MessagesHdrID: TMessagesHdrID = 'Inno Setup Messages (6.0.0)'{$IFDEF UNICODE}+' (u)'{$ENDIF};
@@ -272,13 +272,14 @@ type
     IconName, Filename, Parameters, WorkingDir, IconFilename, Comment: String;
     Components, Tasks, Languages, Check, AfterInstall, BeforeInstall: String;
     AppUserModelID: String;
+    AppUserModelToastActivatorCLSID: TGUID;
     MinVersion, OnlyBelowVersion: TSetupVersionData;
     IconIndex, ShowCmd: Integer;
     CloseOnExit: TSetupIconCloseOnExit;
     HotKey: Word;
     Options: set of (ioUninsNeverUninstall, ioCreateOnlyIfFileExists,
       ioUseAppPaths, ioFolderShortcut, ioExcludeFromShowInNewInstall,
-      ioPreventPinning);
+      ioPreventPinning, ioHasAppUserModelToastActivatorCLSID);
   end;
 const
   SetupIniEntryStrings = 10;

+ 1 - 0
whatsnew.htm

@@ -79,6 +79,7 @@ For conditions of distribution and use, see <a href="https://jrsoftware.org/file
 <p><span class="head2">Other changes</span></p>
 <ul>
   <li>Added new [Run] and [UninstallRun] sections flag: <tt>dontlogparameters</tt>. If this flag is specified, the command line parameters for the program will not be included in the log file.</li>
+  <li>Added new [Icons] section parameter: <tt>AppUserModelToastActivatorCLSID</tt>. Specifies the Windows 10 Application User Model Toast Activator CLSID for the shortcut. Ignored on earlier Windows versions.</li>
   <li>Setup's prompts to overwrite or keep existing files have been made more user friendly:
   <ul>
     <li>If the new FileExists2 message is set by a translation, Setup will use it to show <a href="https://i.imgur.com/AnF6qo8.png">more user friendly prompts</a> to overwrite or keep existing files if the <tt>confirmoverwrite</tt> flag is set.</li>