简体   繁体   中英

Setting correct icon for Shortcut in VS2010 Setup Project

I have a small app with a setup project. If I create a shortcut to my Primary Output, then this gets a standard Win7 icon and not the icon specified in my exe's Application Icon?

Whats the best way to make sure my desktop shortcut icon is the same icon as my exe? eg If I change the exe's icon then I'd like the Setup icon to change as well.

If you set the icon for the shortcut you can set a primary output as source. In the file system editor of the setup project, click on the "(Icon)" combobox in the properties pane of the shortcut, then option "(Browse...)", button "Browse...". You'll see this:

添加输出

Then add output and select the primary output of the exe.

You can add an icon from your target.exe file to the shortcut... in File System On Target Machine, browse to the shortcut in the folder you want to add the icon to (User's Desktop,etc). Right click the shortcut and select Properties Window. You'll see an Icon line... click it, select Browse, then browse to Application Folder/yourExe.exe (change from ICON to Exe files) and say OK. It will show you the icon from yourExe.exe that it has selected, say OK. You basically have to do the same thing for your Add/Remove Icon (appears in Control Panel/Uninstall)... properties page for your setup project. You have to do it for all shortcuts in different folders (User's Desktop, User's Startup, etc.) All icons good now!

To add to Gert's answer: make sure you build your project first. Otherwise the setup app will not see the icon.

Very simple way using IWshShortcut (works in .net 2 too):

WshRuntimeLibrary.IWshShortcut MyShortcut = (IWshRuntimeLibrary.IWshShortcut)WshShell.CreateShortcut(fullPathLnk);    
string iconLoc = MyShortcut.IconLocation; // <- example: "c:\icon.ico,0"

I use to check if iconLoc still exists, fix if not, you can use to find and read icon file, etc etc

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM