Код:

#define MyAppName "My Program"
#define MyAppVersion "1.5"
#define MyAppExeName "MyProg.exe"
[Setup]
AppId={{C50EFAA0-C80A-431E-8698-784F527C6AC4}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes
[Languages]
Name: "english"; MessagesFile: "compiler:Languages\English.isl"
Name: "russian"; MessagesFile: "compiler:Languages\Russian.isl"
[Files]
Source: "compiler:\Examples\MyProg.exe"; DestDir: "{app}"; Flags: ignoreversion
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}";
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\{#MyAppName}"; Filename: "{app}\MyProg.exe"; Check: PinIconCheck;
[code]
var
ComponentPage: TWizardPage;
PinIcon: TNewCheckBox;
function PinIconCheck: Boolean;
begin
Result:=PinIcon.Checked;
end;
const
LOAD_LIBRARY_AS_DATAFILE = $2;
#define A = (Defined UNICODE) ? "W" : "A"
function LoadLibraryEx(lpFileName: String; hFile: THandle; dwFlags: DWORD): THandle; external 'LoadLibraryEx{#A}@kernel32.dll stdcall';
function LoadString(hInstance: THandle; uID: SmallInt; var lpBuffer: Char; nBufferMax: Integer): Integer; external 'LoadString{#A}@user32.dll stdcall';
function SHGetNewLinkInfo(pszLinkTo, pszDir: String; var pszName: Char; var pfMustCopy: Longint; uFlags: UINT): BOOL; external 'SHGetNewLinkInfo{#A}@shell32.dll stdcall';
function PinToTaskbar(const szFilename: String; IsPin: Boolean): Boolean;
var
hInst: THandle;
buf: array [0..255] of Char;
i, res: Integer;
strLnk, strVerb: String;
objShell, colVerbs: Variant;
begin
Result := False;
if (GetWindowsVersion < $06010000) or not FileExists(szFilename) then Exit; { below Windows 7 }
{ String resources }
if IsPin then
begin
if SHGetNewLinkInfo(szFilename, ExpandConstant('{tmp}'), buf[0], res, 0) then
begin
while buf[Length(strLnk)] <> #0 do Insert(buf[Length(strLnk)], strLnk, Length(strLnk)+1);
if FileExists(ExpandConstant('{userappdata}\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\') + ExtractFileName(strLnk)) then Exit;
end;
res := 5386; { Pin to Tas&kbar } { Закрепить на Taskbar }
end else
res := 5387; { Unpin from Tas&kbar } { Открепить от Taskbar }
{ Load string resource }
hInst := LoadLibraryEx(ExpandConstant('{sys}\shell32.dll'), 0, LOAD_LIBRARY_AS_DATAFILE);
if hInst <> 0 then
try
for i := 0 to LoadString(hInst, res, buf[0], 255)-1 do Insert(buf[i], strVerb, i+1);
try
objShell := CreateOleObject('Shell.Application');
colVerbs := objShell.Namespace(ExtractFileDir(szFilename)).ParseName(ExtractFileName(szFilename)).Verbs;
for i := 1 to colVerbs.Count do if CompareText(colVerbs.Item[i].Name, strVerb) = 0 then
begin
colVerbs.Item[i].DoIt;
Result := True;
Break;
end;
except
Exit;
end;
finally
FreeDLL(hInst);
end;
end;
procedure CurPageChanged(CurPageID: integer);
begin
case CurPageID of
wpFinished: begin
if PinIconCheck then PinToTaskbar(ExpandConstant('{app}\MyProg.exe'), True);
end;
end;
end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var
instPath: string;
begin
case CurUninstallStep of
usUninstall: begin
PinToTaskbar(ExpandConstant('{app}\MyProg.exe'), False);
end;
end;
end;
procedure InitializeWizard();
begin
ComponentPage := CreateCustomPage(wpWelcome, 'Выбор типа установки', '...');
WizardForm.SelectTasksLabel.Hide;
{ Pin }
PinIcon := TNewCheckBox.Create(WizardForm);
with PinIcon do
begin
Parent := ComponentPage.Surface;
Left := ScaleX(0);
Top := ScaleY(90);
Width := ScaleX(195);
Height := ScaleY(17);
Caption := 'Закрепить ярлык на панели задач';
end;
end;