I wan't to customize the icon displayed within the windows 7 taskbar. When my app is running, I can do it by changing main window icon but, when the app is pinned, the exe's icon is displayed.
我不想自定义显示在windows 7任务栏中的图标。当我的应用程序运行时,我可以通过改变主窗口图标来实现,但是当应用程序被固定时,exe的图标就会显示出来。
How can I set the taskbar icon for my app to an icon different from the one embedded within the exe ?
如何将应用程序的任务栏图标设置为与exe中嵌入的图标不同的图标?
Not tried, this solution may work but looks dirty.
没有尝试,这个解决方案可能有效,但是看起来很脏。
Edit :
编辑:
Our app is compiled once but depending on config file, features are enabled or not so it's a product or another. We do not want to compile one exe for each product.
我们的应用程序只编译一次,但取决于配置文件,功能是否被启用,所以它是一个产品或另一个产品。我们不想为每个产品编译一个exe。
The solution above may not work as many instances of my app can be installed in different pathes (so you end up with the same exe file name but different icons!), is this registry key poorly designed or am I missing something?
上面的解决方案可能不能工作,因为我的应用程序的许多实例可以安装在不同的路径中(所以您最终会得到相同的exe文件名,但是不同的图标!)
9 个解决方案
#1
23
EDIT The info below is a bit obsolete; all new Windows 7 bits are now available as a managed API, available here: http://code.msdn.microsoft.com/WindowsAPICodePack
编辑下面的信息有点过时;所有新的Windows 7位现在都可以作为托管API使用,这里有http://code.msdn.microsoft.com/WindowsAPICodePack
There is a series of articles on the new Taskbar API by the debugging guru Sasha Goldshtein. You should have a look at the Overlay Icons and Progress Bars API.
有一系列关于调试大师Sasha Goldshtein新的任务栏API的文章。您应该看一下叠加图标和进度条API。
You can download the sample code from Windows 7 Taskbar Developer Resources on Microsoft Code. What you're looking for is the IMClient
sample:
您可以从Microsoft代码上的Windows 7 Taskbar开发人员资源中下载示例代码。你要找的是IMClient样本
The IMClient sample demonstrates how taskbar overlay icons and taskbar progress bars can light up an application’s taskbar button instead of relying on an additional dialog or on an icon in the system notification area (tray).
IMClient示例演示了任务栏叠加图标和任务栏进度条如何点亮应用程序的任务栏按钮,而不是依赖于附加的对话框或系统通知区域(tray)中的图标。
I believe this should help you achieve what you want.
我相信这会帮助你实现你想要的。
#2
16
When you pin an application to the TaskBar, it simply creates a shortcut in the following directory:
当您将应用程序固定到任务栏时,它只是在以下目录中创建一个快捷方式:
C:\Users\<User Name>\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar
You should be able to identify where the shortcut is (ie, get KnownFolders and work from there. UserAppData should be the one), and then using P/Invoke (IShellLink), you can alter the icon that the shortcut is setup to use. The machine might need a reboot for this to take effect, but it should work.
您应该能够识别快捷方式在哪里(例如,获取已知文件夹并从那里开始工作)。UserAppData应该是其中之一),然后使用P/Invoke (IShellLink),您可以修改快捷方式要使用的图标。机器可能需要重新启动才能生效,但它应该可以工作。
If you hold down Shift while right-clicking on the pinned application, and select Properties, you can see the Change Icon button for the shortcut. This is basically what you need to emulate with code.
如果在按下Shift键的同时右键单击固定应用程序,并选择Properties,则可以看到快捷方式的Change图标按钮。这基本上就是您需要用代码模拟的。
All of these things can definately be done with code, but whether you think they're any better than the registry setting is up to you.
所有这些事情都可以通过代码来完成,但是您是否认为它们比注册表设置更好。
#3
1
You can do this by using the library called "Windows 7 Bridge" which is based on the "Windows Vista Bridge".
您可以使用基于“Windows Vista桥”的名为“Windows 7桥”的库来实现这一点。
These are managed wrappers around all the Vista and Windows 7 native functions.
这些是所有Vista和Windows 7本机功能的托管包装器。
More info can be found here
更多信息可以在这里找到。
#4
1
I don't know if I'm understanding your problem but..
我不知道我是否理解你的问题。
If you create an application and put the icon property of the main window, that icon will appear in the taskbar also. But, if you pin-it to the taskbar, that icon dissapear. Am I right? If so, go to the project properties and in the application tab, put the icon that you want for the exe. Now, you will see that icon in the taskbar when pinned.
如果您创建一个应用程序并将主窗口的图标属性设置为,该图标也会出现在任务栏中。但是,如果你把它输入任务栏,这个图标就会消失。我说的对吗?如果是,请转到项目属性,并在application选项卡中放置您想要的exe图标。现在,您将在任务栏中看到该图标。
I Use the same icon for both things :P
我用相同的图标表示两件事:P
#5
1
As far as I can tell, for some reason you can't change the icon for a program that's already pinned to the taskbar. To do it, just unpin the program, locate it in the start menu, right click - properties - change icon. then re-pin it to the taskbar, and it will have the new icon!
据我所知,由于某些原因,你无法更改已经固定在任务栏上的程序的图标。要做到这一点,只需打开程序,在开始菜单中找到它,右键单击-属性-更改图标。然后把它重新固定到任务栏,它就会有新的图标!
#6
0
Have a look at this blog. He does a series of blog posts about programming the Windows 7 taskbar, so maybe that will point you in the right direction.
看看这个博客。他写了一系列关于Windows 7任务栏编程的博客文章,所以这可能会让你找到正确的方向。
#7
0
I can't test this right now unfortunately, but perhaps just creating a regular, good old shortcut might solve the problem? Create a shortcut to the app, change the icon, then pin the shortcut instead of the app itself?
不幸的是,我现在不能测试这个,但是也许仅仅创建一个常规的,好的旧的快捷方式就可以解决这个问题?创建一个快捷方式的应用,改变图标,然后钉住快捷方式,而不是应用本身?
Will check when I can next get access to my Windows 7 machine...
将检查我什么时候可以访问我的Windows 7机器……
#8
0
Right click on the pinned icon, in the popup you see the programs title, there right click again and go to properties. There you are able to change the icon by clicking on the button "change icon". For me it needed a reboot to finish the changes.
右击固定图标,在弹出窗口中你看到程序标题,右击再次点击属性。在那里,你可以通过点击“改变图标”按钮来改变图标。对我来说,需要重新启动才能完成更改。
#9
-1
If you want to have a shortcut in the taskbar that goes directly to somewhere useful, such as your "My Documents" directory. The easy fix . . .
如果您想要在任务栏中有一个快捷方式,可以直接到某个有用的地方,比如“我的文档”目录。简单的解决方法…
Drop a folder into the taskbar ( which creates a shortcut to images ). Navigate to the directory where that shortcut was placed, right click on the shortcut and select "properties" to change the target. Select the "general" tab to change the name of the shortcut. The shortcut was placed here:
将文件夹放到任务栏中(任务栏创建图像的快捷方式)。导航到放置该快捷方式的目录,右键单击该快捷方式并选择“properties”以更改目标。选择“general”选项卡更改快捷方式的名称。捷径被放在这里:
C:\Users[user]\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar
C:\[用户]\ AppData \漫游用户\ \快速启动\ \ Microsoft Internet Explorer用户固定\任务栏
You can navigate to this directory and edit the properties of the "images" shortcut.
您可以导航到这个目录,并编辑“图像”快捷方式的属性。
#1
23
EDIT The info below is a bit obsolete; all new Windows 7 bits are now available as a managed API, available here: http://code.msdn.microsoft.com/WindowsAPICodePack
编辑下面的信息有点过时;所有新的Windows 7位现在都可以作为托管API使用,这里有http://code.msdn.microsoft.com/WindowsAPICodePack
There is a series of articles on the new Taskbar API by the debugging guru Sasha Goldshtein. You should have a look at the Overlay Icons and Progress Bars API.
有一系列关于调试大师Sasha Goldshtein新的任务栏API的文章。您应该看一下叠加图标和进度条API。
You can download the sample code from Windows 7 Taskbar Developer Resources on Microsoft Code. What you're looking for is the IMClient
sample:
您可以从Microsoft代码上的Windows 7 Taskbar开发人员资源中下载示例代码。你要找的是IMClient样本
The IMClient sample demonstrates how taskbar overlay icons and taskbar progress bars can light up an application’s taskbar button instead of relying on an additional dialog or on an icon in the system notification area (tray).
IMClient示例演示了任务栏叠加图标和任务栏进度条如何点亮应用程序的任务栏按钮,而不是依赖于附加的对话框或系统通知区域(tray)中的图标。
I believe this should help you achieve what you want.
我相信这会帮助你实现你想要的。
#2
16
When you pin an application to the TaskBar, it simply creates a shortcut in the following directory:
当您将应用程序固定到任务栏时,它只是在以下目录中创建一个快捷方式:
C:\Users\<User Name>\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar
You should be able to identify where the shortcut is (ie, get KnownFolders and work from there. UserAppData should be the one), and then using P/Invoke (IShellLink), you can alter the icon that the shortcut is setup to use. The machine might need a reboot for this to take effect, but it should work.
您应该能够识别快捷方式在哪里(例如,获取已知文件夹并从那里开始工作)。UserAppData应该是其中之一),然后使用P/Invoke (IShellLink),您可以修改快捷方式要使用的图标。机器可能需要重新启动才能生效,但它应该可以工作。
If you hold down Shift while right-clicking on the pinned application, and select Properties, you can see the Change Icon button for the shortcut. This is basically what you need to emulate with code.
如果在按下Shift键的同时右键单击固定应用程序,并选择Properties,则可以看到快捷方式的Change图标按钮。这基本上就是您需要用代码模拟的。
All of these things can definately be done with code, but whether you think they're any better than the registry setting is up to you.
所有这些事情都可以通过代码来完成,但是您是否认为它们比注册表设置更好。
#3
1
You can do this by using the library called "Windows 7 Bridge" which is based on the "Windows Vista Bridge".
您可以使用基于“Windows Vista桥”的名为“Windows 7桥”的库来实现这一点。
These are managed wrappers around all the Vista and Windows 7 native functions.
这些是所有Vista和Windows 7本机功能的托管包装器。
More info can be found here
更多信息可以在这里找到。
#4
1
I don't know if I'm understanding your problem but..
我不知道我是否理解你的问题。
If you create an application and put the icon property of the main window, that icon will appear in the taskbar also. But, if you pin-it to the taskbar, that icon dissapear. Am I right? If so, go to the project properties and in the application tab, put the icon that you want for the exe. Now, you will see that icon in the taskbar when pinned.
如果您创建一个应用程序并将主窗口的图标属性设置为,该图标也会出现在任务栏中。但是,如果你把它输入任务栏,这个图标就会消失。我说的对吗?如果是,请转到项目属性,并在application选项卡中放置您想要的exe图标。现在,您将在任务栏中看到该图标。
I Use the same icon for both things :P
我用相同的图标表示两件事:P
#5
1
As far as I can tell, for some reason you can't change the icon for a program that's already pinned to the taskbar. To do it, just unpin the program, locate it in the start menu, right click - properties - change icon. then re-pin it to the taskbar, and it will have the new icon!
据我所知,由于某些原因,你无法更改已经固定在任务栏上的程序的图标。要做到这一点,只需打开程序,在开始菜单中找到它,右键单击-属性-更改图标。然后把它重新固定到任务栏,它就会有新的图标!
#6
0
Have a look at this blog. He does a series of blog posts about programming the Windows 7 taskbar, so maybe that will point you in the right direction.
看看这个博客。他写了一系列关于Windows 7任务栏编程的博客文章,所以这可能会让你找到正确的方向。
#7
0
I can't test this right now unfortunately, but perhaps just creating a regular, good old shortcut might solve the problem? Create a shortcut to the app, change the icon, then pin the shortcut instead of the app itself?
不幸的是,我现在不能测试这个,但是也许仅仅创建一个常规的,好的旧的快捷方式就可以解决这个问题?创建一个快捷方式的应用,改变图标,然后钉住快捷方式,而不是应用本身?
Will check when I can next get access to my Windows 7 machine...
将检查我什么时候可以访问我的Windows 7机器……
#8
0
Right click on the pinned icon, in the popup you see the programs title, there right click again and go to properties. There you are able to change the icon by clicking on the button "change icon". For me it needed a reboot to finish the changes.
右击固定图标,在弹出窗口中你看到程序标题,右击再次点击属性。在那里,你可以通过点击“改变图标”按钮来改变图标。对我来说,需要重新启动才能完成更改。
#9
-1
If you want to have a shortcut in the taskbar that goes directly to somewhere useful, such as your "My Documents" directory. The easy fix . . .
如果您想要在任务栏中有一个快捷方式,可以直接到某个有用的地方,比如“我的文档”目录。简单的解决方法…
Drop a folder into the taskbar ( which creates a shortcut to images ). Navigate to the directory where that shortcut was placed, right click on the shortcut and select "properties" to change the target. Select the "general" tab to change the name of the shortcut. The shortcut was placed here:
将文件夹放到任务栏中(任务栏创建图像的快捷方式)。导航到放置该快捷方式的目录,右键单击该快捷方式并选择“properties”以更改目标。选择“general”选项卡更改快捷方式的名称。捷径被放在这里:
C:\Users[user]\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar
C:\[用户]\ AppData \漫游用户\ \快速启动\ \ Microsoft Internet Explorer用户固定\任务栏
You can navigate to this directory and edit the properties of the "images" shortcut.
您可以导航到这个目录,并编辑“图像”快捷方式的属性。