Yaliang Posted May 8, 2014 Posted May 8, 2014 (edited) Use COM methods and properties via the COM Automation objects support.So I translate a Delphi script to Inno Setup section.And it work! Here is a part of script in [code] section:[code]http://www.jrsoftware.org)There are someway to pin taskbar depend on one's choice.We can add a [task] section in InnoSetup.if one do not want to see the "task selected page"(like me ),the second way is to create a new CheckBox in Inno [code] section.And in the second way one need to control the CheckBox show or hide inprocedure CurPageChanged().then call the function like: zylPinAppToTaskbar('c:\window', 'notepad.exe'); An example project for Unicode Inno Setup is provided as download.The attachment "pintaskbar.zip" is the script.Unzip the file pintaskbar.zip,you can get two files named "PinShortcutOntoTaskbar-task.iss"and "PinShortcutOntoTaskbar-checkbox.iss".Please copy the *.iss files to the directory: ./Inno Setup 5/ExamplesThen build the program and run PinTaskbar.exe. Referenceshttp://blog.csdn.net/ccrun/article/details/6906471http://gallery.technet.microsoft.com/ScriptCenter/b66434f1-4b3f-4a94-8dc3-e406eb30b750/http://www.codeproject.com/Tips/713824/Pin-a-shortcut-onto-the-Taskbar-or-Start-Menu The following is the script of the second way, I think you can modify it to the first way.If the attachment was broken, copy the following script to a *.iss file. ; -- PinShortcutOntoTaskbar.iss --; Pin a shortcut onto taskbar on Win7 & Win8.; @author: Yaliang.Zhao <shuangxiang2008@google.com>; @brief: I test is on 32-bit Win7 & Win8, but; I thins it will work on X64 version.[setup]AppName=PinTaskbarAppVersion=1.0OutputBaseFilename=PinTaskbarDefaultDirName={pf}\PinTaskbarOutputDir=./DisableStartupPrompt=yesDisableReadyPage=yes[Files]Source: "MyProg.exe"; DestDir: "{app}";[Tasks];Name: pintaskbar; Description: "Pin shortcut onto taskbar";Following is how to use[Code]varPinTaskBarCheck : TNewCheckBox;//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 APIfunction LoadLibrary(lpFilename : String) : LongInt;external 'LoadLibraryW@kernel32.dll stdcall delayload'; //if Non Unicode Inno Setup, use LoadLibraryAfunction FreeLibrary(hModule : LongInt) : BOOL;external 'FreeLibrary@kernel32.dll stdcall delayload';function LoadString(hInstance:LongInt; uId:UINT; lpBuffer:String; nBufferMax:Integer) : Integer;external 'LoadStringW@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, 5386, szPinName, 255); FreeLibrary(h); strEnd := #0; filenameEnd := Pos(strEnd, szPinName); filename := Copy(szPinName, 1, filenameEnd - 1); 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; 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 thisprocedure CurPageChanged(CurPageID: Integer);begin //When Finished page is shown, call the function //You can also call is when the "Finish" button clicked. if CurPageID <> wpWelcome then PinTaskBarCheck.hide else begin PinTaskBarCheck.show; end; if CurPageID = wpFinished then begin //if IsTaskSelected('pintaskbar') then //if Selected the [task] // zylPinAppToTaskbar(ExpandConstant('{app}'), 'MyProg.exe'); if PinTaskBarCheck.Checked then zylPinAppToTaskbar(ExpandConstant('{app}'), 'MyProg.exe'); end;end;procedure InitializeWizard;begin PinTaskBarCheck := TNewCheckBox.Create(WizardForm); with PinTaskBarCheck do begin Parent := WizardForm; Caption := 'Pin it onto taskbar'; Top := 200; Left := 200; Width := ScaleY(200); Height := ScaleY(15); State := cbChecked; //Hide; end;end;pintaskbar.zip Edited May 9, 2014 by shuangxiang2008@googlemail SunLion and alfreire 2 Quote
alfreire Posted May 8, 2014 Posted May 8, 2014 Anybody know how use this code in InnoSetup with a example...?Thanks and regards... ;-) Quote
Yaliang Posted May 9, 2014 Author Posted May 9, 2014 Anybody know how use this code in InnoSetup with a example...?Thanks and regards... ;-)I had rewriten the article, and provided an example in the attachment "pintaskbar.zip". alfreire 1 Quote
ricktendo Posted May 9, 2014 Posted May 9, 2014 THIS IS AWESOME!!! Works like a charm alfreire and SunLion 2 Quote
Yaliang Posted May 12, 2014 Author Posted May 12, 2014 THIS IS AWESOME!!!Works like a charmThanks for your replyHope it can help you. Quote
ricktendo Posted May 12, 2014 Posted May 12, 2014 Already has, I added it to my AIDA64 installer and its working perfectly (even removes it on uninstall) SunLion and alfreire 2 Quote
Yaliang Posted May 12, 2014 Author Posted May 12, 2014 Already has, I added it to my AIDA64 installer and its working perfectly (even removes it on uninstall)remove the shortcuts form taskbar, I think it need to delete the shorcuts form the special directory.C:\Users\Current User\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar.(The directory is hide.) alfreire 1 Quote
alfreire Posted May 12, 2014 Posted May 12, 2014 (edited) Already has, I added it to my AIDA64 installer and its working perfectly (even removes it on uninstall)remove the shortcuts form taskbar, I think it need to delete the shorcuts form the special directory.C:\Users\Current User\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar.(The directory is hide.) Thanks again...!!!Regards... ;-) Already has, I added it to my AIDA64 installer and its working perfectly (even removes it on uninstall)How you delete the shortcut at uninstall...? deleting the shortcut in C:\Users\Current User\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar...?Regards... ;-) Edited May 12, 2014 by alfreire Quote
Yaliang Posted May 12, 2014 Author Posted May 12, 2014 Already has, I added it to my AIDA64 installer and its working perfectly (even removes it on uninstall)remove the shortcuts form taskbar, I think it need to delete the shorcuts form the special directory.C:\Users\Current User\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar.(The directory is hide.) Thanks again...!!!Regards... ;-) Already has, I added it to my AIDA64 installer and its working perfectly (even removes it on uninstall)How you delete shortcut at uninstall...? deleting the link...?Regards... ;-) Maybe U can see the [uninstallDelete] section in InnoSetup documentation.I am trying to find a way in section.but not finished.In theory, pin or unpin is the same way. alfreire and SunLion 2 Quote
ricktendo Posted May 12, 2014 Posted May 12, 2014 I don't have to do anything extra, for some reason mine is deleted automatically on uninstall (which is a nice thing) Quote
alfreire Posted May 12, 2014 Posted May 12, 2014 I don't have to do anything extra, for some reason mine is deleted automatically on uninstall (which is a nice thing)Yes it's true, shortcut is delete during uninstall... only not delete when use Uninstallable=no in [setup]...Regards... ;-) Quote
Yaliang Posted May 13, 2014 Author Posted May 13, 2014 I don't have to do anything extra, for some reason mine is deleted automatically on uninstall (which is a nice thing) It is a good news!Regards... ;-) Quote
Yaliang Posted May 13, 2014 Author Posted May 13, 2014 I don't have to do anything extra, for some reason mine is deleted automatically on uninstall (which is a nice thing)Yes it's true, shortcut is delete during uninstall... only not delete when use Uninstallable=no in [setup]...Regards... ;-) It is helpful...Regards... ;-) alfreire 1 Quote
BYTE-ME Posted May 15, 2014 Posted May 15, 2014 I'm no Inno expert. In fact, this is my first time using it. So I'm lost here. If I have an existing program installed on my PC and I want to create an installer that automatically pins it to the taskbar. I'm trying to figure out which code to modify in shuangxiang2008 included "PinShortcutOntoTaskbar-task.iss" script. Must I do something more than modify the paths to: (ExpandConstant('{app}') and the entry under [Files] Source: Thanks Quote
alfreire Posted May 15, 2014 Posted May 15, 2014 I'm no Inno expert. In fact, this is my first time using it. So I'm lost here. If I have an existing program installed on my PC and I want to create an installer that automatically pins it to the taskbar. I'm trying to figure out which code to modify in shuangxiang2008 included "PinShortcutOntoTaskbar-task.iss" script. Must I do something more than modify the paths to: (ExpandConstant('{app}') and the entry under [Files] Source: ThanksHi... to help you better, what is the program, which you want make installer...?Regards... ;-) SunLion 1 Quote
Yaliang Posted May 16, 2014 Author Posted May 16, 2014 I'm no Inno expert. In fact, this is my first time using it. So I'm lost here. If I have an existing program installed on my PC and I want to create an installer that automatically pins it to the taskbar. I'm trying to figure out which code to modify in shuangxiang2008 included "PinShortcutOntoTaskbar-task.iss" script. Must I do something more than modify the paths to: (ExpandConstant('{app}') and the entry under [Files] Source: ThanksI think your program is repacked by Inno.If you want to automatically pins it onto the taskbar, maybe you just need to modify the function CurPageChanged() ,you can remove IsTaskSelected()function,and remove the [task] section.like following: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 //if Selected the [task] zylPinAppToTaskbar(ExpandConstant('{app}'), 'MyProg.exe'); end;end;Hope can help you.Regards... ;-) alfreire 1 Quote
BYTE-ME Posted May 17, 2014 Posted May 17, 2014 (edited) As an example, say I want to put a shortcut in the taskbar for magnify.exe, which is included with windows in the system32 folder. Since the program magnify.exe already exists, can I make an inno installer to install the taskbar shortcut pointing to magnify.exe since I now have to do this manually after a clean install? Edited May 17, 2014 by BYTE-ME Quote
alfreire Posted May 17, 2014 Posted May 17, 2014 (edited) If I'm not mistaken:[Code]varPinTaskBarCheck : TNewCheckBox;//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 APIfunction LoadLibrary(lpFilename : String) : LongInt;external 'LoadLibraryW@kernel32.dll stdcall delayload'; //if Non Unicode Inno Setup, use LoadLibraryAfunction FreeLibrary(hModule : LongInt) : BOOL;external 'FreeLibrary@kernel32.dll stdcall delayload';function LoadString(hInstance:LongInt; uId:UINT; lpBuffer:String; nBufferMax:Integer) : Integer;external 'LoadStringW@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, 5386, szPinName, 255); FreeLibrary(h); strEnd := #0; filenameEnd := Pos(strEnd, szPinName); filename := Copy(szPinName, 1, filenameEnd - 1); 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; 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 thisprocedure 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('{sys}'), 'magnify.exe'); end;end;zylPinAppToTaskbar(ExpandConstant('{sys}'), 'magnify.exe'); Regards... ;-) Edited May 17, 2014 by alfreire SunLion 1 Quote
Yaliang Posted May 19, 2014 Author Posted May 19, 2014 As an example, say I want to put a shortcut in the taskbar for magnify.exe, which is included with windows in the system32 folder. Since the program magnify.exe already exists, can I make an inno installer to install the taskbar shortcut pointing to magnify.exe since I now have to do this manually after a clean install?use the function zylPinAppToTaskbar(), you just need two parameter,first, the dirctory of the *.exe;second, the real name of *.exe.maybe you must sure that *.exe is exist.then call the function where you need. Quote
alfreire Posted September 28, 2014 Posted September 28, 2014 (edited) Slightly improved code... Change this:function LoadLibrary(lpFilename : String) : LongInt;external 'LoadLibraryW@kernel32.dll stdcall delayload'; //if Non Unicode Inno Setup, use LoadLibraryAfunction FreeLibrary(hModule : LongInt) : BOOL;external 'FreeLibrary@kernel32.dll stdcall delayload';function LoadString(hInstance:LongInt; uId:UINT; lpBuffer:String; nBufferMax:Integer) : Integer;external 'LoadStringW@user32.dll stdcall delayload'; //if Non Unicode Inno Setup, use LoadStringAto this:#ifdef UNICODE #define A "W"#else #define A "A"#endiffunction LoadLibrary(lpFilename : String) : LongInt;external 'LoadLibrary{#A}@kernel32.dll stdcall delayload'; 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'; to automatic Unicode/No Unicode library selection... not my code, I found searching in internet... (I don't know programming... X-D) Regards... ;-) Edited September 20, 2015 by alfreire Quote
Yaliang Posted October 28, 2014 Author Posted October 28, 2014 It is a very good change.Regards... ;-) Slightly improved code... Change this:function LoadLibrary(lpFilename : String) : LongInt;external 'LoadLibraryW@kernel32.dll stdcall delayload'; //if Non Unicode Inno Setup, use LoadLibraryAfunction FreeLibrary(hModule : LongInt) : BOOL;external 'FreeLibrary@kernel32.dll stdcall delayload';function LoadString(hInstance:LongInt; uId:UINT; lpBuffer:String; nBufferMax:Integer) : Integer;external 'LoadStringW@user32.dll stdcall delayload'; //if Non Unicode Inno Setup, use LoadStringAto this:#ifdef UNICODE #define A "W"#else #define A "A"#endiffunction LoadLibrary(lpFilename : String) : LongInt;external 'LoadLibrary{#A}@kernel32.dll stdcall delayload'; 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'; to automatic Unicode/No Unicode library selection... not my code, I found searching in internet... (I don'tt know programming... X-D) Regards... ;-) SunLion and alfreire 2 Quote
Taweesak Sodjit Posted March 4, 2022 Posted March 4, 2022 OK Work KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK http://forum.oszone.net/post-2834519-92.html Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.