Change pinned taskbar icon (windows 7) - c#

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.
How can I set the taskbar icon for my app to an icon different from the one embedded within the 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.
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?

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
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.
You can download the sample code from Windows 7 Taskbar Developer Resources on Microsoft Code. What you're looking for is the IMClient sample:
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).
(source: microsoft.co.il)
(source: microsoft.co.il)
(source: microsoft.co.il)
I believe this should help you achieve what you want.

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.
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.
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.

You can do this by using the library called "Windows 7 Bridge" which is based on the "Windows Vista Bridge".
These are managed wrappers around all the Vista and Windows 7 native functions.
More info can be found here

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.
I Use the same icon for both things :P

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!

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.

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...

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.

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:
C:\Users[user]\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar
You can navigate to this directory and edit the properties of the "images" shortcut.

Related

c# running application icon duplicates on taskbar instead of highlight shortcut

I've a .NET 4.0 C# WinForm application and the related shortcut placed on taskbar. In Windows 7, after application starts, the icon of the shortcut in taskbar is "highlighted" as i expect. Differently, in Windows 10, after program starts, a second app icon appears on the taskbar as the rightmost one, and the shortcut icon remains without "highlight".
Someone may help me?
I've solved this issue re-creating and re-pinning to the Win10 taskbar the shortcut (.lnk) to the application.
As Hans Passant (thanks Hans) pointed out in comments to the question, this may be a behaviour related to the system-assigned AppUserModelIDs. Read https://learn.microsoft.com/en-us/windows/desktop/shell/appids for complete infos.
Maybe you need to re-create shortcut any time you modify and recompile your app.

How to add "Last used documents" to a WPF programms tray symbol (not icon) programatically?

I want to provide a list of "last used documents" to the bigger tray icon (not notification icons) of my application.
As shortcut to the user, similar to like Keypass or Microsoft Word do it when right clicking on it's tray icon if the application is started.
I do not want to put them into the tray icon context menu.
I am unsure if that is a feature that Word provides or if its somehow linked to "what files should be opened by which application" of Windows itself.
I have searched SO / google with keywords like "tray icon", "last used documents" - but the hits more or less discuss
how to change the icon of a program
how to addthe smaller icons to the far right of the screen
how to create apps w/o them popping up in the tray bar at all
how to create context menues on tray icons
I got all of that already.
I was unable to find questions related to the popup in the above picture that is there when the program is running.
Any ideas?
Q&A from comments:
Feature is called jump-list / Tasks , thanks to #PanagiotisKanavos
Screenshot is Windows 10, I need it back for Win 8 if appliccable. I can sort the Win 8/8.1 stuff out myself if I get some hints what to look for in Win 10.

Disable Taskbar in Windows 10

Is there any way to completely disable the taskbar in Windows 10 Home? I have a C# app that I want to display fullscreen on clients' displays without any sign of it running on Windows. It's supposed to run on startup and display a website.
I created a setup that changes most of the Windows settings via registry, like hiding desktop icons and altering logon view, but the taskbar remains visible. Auto hide doesn't satisfy me, because after the system boots the taskbar is still visible until you actually click somewhere on the desktop, and it takes a while for my app to run. I'd really appreciate some help.
When explorer is running, there taskbar will always be visible in some kind (even if it's a small border).
If you want to achieve something like a digital signage solution, you may replace the shell. Changing the shell will also provide some other benefits (most popups / balloontips won't occur anymore).
Be aware that this configuration is effective for all users on the system.
Path to the shell is available at
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\WinLogon\Shell
Update:
Just to hightlight:
It is indeed possible to have custom shells per user (see comments).
This is done by specifying a custom location of the shell path that is located in the registry for a given user.
Yes, you can totally disable the taskbar in Windows 10 but it is only temporary until you hover your mouse around the taskbar area.
Here's a tutorial: how to hide the taskbar in Windows 10

My own taskbar for Win CE

I've created WinCE 6.0 image without taskbar. So all app's maximized to full screen.
I want create my own app like taskbar. I want add only few buttons to this taskbar. But I want That other app in their maximized mode don't hide this task bar. And I don't want make my all top most, because they hide some part of other app.
How can I make my app like task bar?
You could modify the existing taskbar in the current Explore shell (source at %WINCEROOT%\PUBLIC\SHELL\OAK\HPC\EXPLORER\TASKBAR\taskbar.cpp or is that's not flexible enough, you could create your own Shell and create your own "taskbar-like" behavior however you'd like.
In either case, remember to clone the code to your own BSP tree! Don't modify the public tree.
The approach I've taken and works is to write a custom kiosk shell based on the explorer.exe code built in visual studio. You could use platform builder as well, kind of the same tool now a days. Looking back I'd say it was a bit heavy handed and it took a little bit of refactoring to CTaskBar and explorer to subclass CTaskBar to our needs, but it produced a shell that we could lock and unlock with complete explorer capabilities. Perhaps a lighterweight approach would be to register your app's window as the taskbar (sorry the system call escapes me) and handle the taskbar specific messages in your winproc?

WPF app has no "Pin to Taskbar" option

I have created a couple of WPF apps but when right clicking them in the Windows 7 Taskbar I just get a Close Windows Option, usually there is a Pin to Taskbar option, I don't know where this has gone, is there anything that needs to be enabled or anything.
I am using:
VS2010 + Blend 4 with .NET Framework 3.5SP1
Your shortcut for the WPF Application requires an AppUserModelID. This is a property that can be set on any .lnk shortcut. Once Windows knows the AppUserModelID it provides the new features of the Taskbar to the app, including taskbar icon glomming which groups several open windows of the same app together. If you use MSI to install your apps you can use the MsiShortcutProperty table and set AppIDProperty for your app's shortcut. The value takes the following form:
For your MsiShortcutProperty table, add the following values to the table:
Columns/values:
MsiShortcutProperty/AppIDProperty
Shortcut_/MyShortcut.<guid>
PropertyKey/System.AppUserModel.ID
PropVariantValue/<YourCompanyName.ProductName.SubProduct.VersionInformation>
You can also look at the following article which explains how the ID is used and can be set on a shortcut programmatically: http://msdn.microsoft.com/en-us/library/dd378459%28VS.85%29.aspx#where
I think you need to look into this http://code.msdn.microsoft.com/Windows7Taskbar

Categories