Inno Setup -> Add App Pin to Task Bar

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
dev09Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sinisa VukSoftware architectCommented:
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

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Installation

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.