Inno Setup -> Add App Pin to Task Bar

dev09
dev09 used Ask the Experts™
on
Hi all,

I want to be able to use 'Inno Setup' (http://www.jrsoftware.org/isinfo.php) to not only install a WIndows exe file but to also pin a shortcut to the installed App in the Task Bar.

I've found this link: http://www.wincert.net/forum/topic/11963-inno-setup-how-to-pin-program-to-taskbar-in-win-7/
But unable to get it working properly.

Is someone able to give me some advice on how to get it working or another solution that may work?

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Software architect
Top Expert 2012
Commented:
I found this code: and modified like (code block in script):
[Code]
//the function is work well on Unicode Inno Setup, 
//if Non Unicode Inno Setup, one need to modify,
//and I think you can do it!
//Inno use Win32 API
const
  // these constants are not defined in Windows
  SHELL32_STRING_ID_PIN_TO_TASKBAR = 5386;
  SHELL32_STRING_ID_PIN_TO_STARTMENU = 5381;
  SHELL32_STRING_ID_UNPIN_FROM_TASKBAR = 5387;
  SHELL32_STRING_ID_UNPIN_FROM_STARTMENU = 5382;

#ifdef UNICODE
    #define A "W"
#else
    #define A "A"
#endif
function LoadLibrary(lpFilename : String) : LongInt;
external 'LoadLibrary{#A}@kernel32.dll stdcall delayload';  //if Non Unicode Inno Setup, use LoadLibraryA
function FreeLibrary(hModule : LongInt) : BOOL;
external 'FreeLibrary@kernel32.dll stdcall delayload';
function LoadString(hInstance:LongInt; uId:UINT; lpBuffer:String; nBufferMax:Integer) : Integer;
external 'LoadString{#A}@user32.dll stdcall delayload';  //if Non Unicode Inno Setup, use LoadStringA

//here is the function
//@param strPath The App's directory,
//@param strApp The App's name
//@example zylPinAppToTaskbar('c:\window', 'notepad.exe');
procedure zylPinAppToTaskbar(strPath, strApp: string);  
var  
  vShell, vFolder, vFolderItem, vItemVerbs: Variant;  
  vPath, vApp: Variant;  
  i: Integer;  
  sItem: String;   
  h: LongInt; 
  szPinName: String; 
  filenameEnd : Integer;
  filename    : String; 
  strEnd    : String;
begin 
  SetLength(szPinName, 255); 
  h := LoadLibrary(ExpandConstant('{sys}\Shell32.dll'));  
  LoadString(h, SHELL32_STRING_ID_PIN_TO_TASKBAR, szPinName, 255); //pin to taskbar text 
  FreeLibrary(h);  
  strEnd := #0;
  filenameEnd := Pos(strEnd, szPinName);
  filename := Copy(szPinName, 1, filenameEnd - 1);
  MsgBox(filename, mbInformation, MB_OK);
  if (Length(filename) > 0) then  //WinXp or lower, no pin taskbar function
  begin
    vShell := CreateOleObject('Shell.Application');  
    vPath := strPath;  
    vFolder := vShell.NameSpace(vPath);  
    vApp := strApp;  
    vFolderItem := vFolder.ParseName(vApp);  
    vItemVerbs := vFolderItem.Verbs;  
     
    for i := 1 to vItemVerbs.Count do  
    begin  
      sItem := vItemVerbs.Item(i).Name;
      MsgBox(sItem, mbInformation, MB_OK);

      if (sItem = filename) then
      begin
        // 63 63 72 75 6E 2E 63 6F 6D  
        vItemVerbs.Item(i).DoIt; 
        break; 
      end; 
    end;  
  end;
end;  

//You can use zylPinAppToTaskbar like this
procedure CurPageChanged(CurPageID: Integer);
begin
  //When Finished page is shown, call the function
  //You can also call is when the "Finish" button clicked.
  if  CurPageID = wpFinished then  
  begin
  if IsTaskSelected('pintaskbar') then
    zylPinAppToTaskbar(ExpandConstant('{app}'), 'MyProg.exe');
  end;
end;

Open in new window


- please change MyProg.exe to real name.
-add task to [Tasks]
Name: "pintaskbar"; Description: "Pin to Taskbar"; GroupDescription: "Pin program to Taskbar"; Flags: unchecked

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial