How to set a little icon on files under windows? - c#

i would to set dynamically a little icon on the files (maybe on folders too) that i lock with my app.
I saw it with google app for synchronize, a little "refresh icon" appears to symbolize they are in synchronization, and i want make the same thing with my app that lock temporarely files to prevent changement meanwhile it works on it.
I Imagine it must use c++ api for Windows ?
It needs to change all the icon or with windows 10 you can add by a layer another icon ?
How to change dynamically an icon files ?
thanks.
Informations:
Environnement: Windows10.
Target: Files icon.
Language: c#, maybe
c++ api windows.

You can assign icons to the members of the file type by implementing
an icon handler. An icon handler is a type of Shell extension handler
that allows you to dynamically assign icons to the members of a file
type.
Refer to "How to Create Icon Handlers".
Similar topic: "How to create a IconHandler used by the shell in c++?"

Related

When creating a custom file extension, is it possible to assign it an icon different from the application icon?

Hello wonderful people!
I have created some code for an application which upon startup, simply makes sure the registry has a key for my own file extension (or I guess 'class', as Windows calls it). It allows me to double-click a file with said extension and have it open with my program. Simple.
My query is this; is it possible for me to change the icon for this file class, to be different from the icon of my application? I would prefer to have some different icons for the various file extensions I'm registering, much in the same way that Photoshop for example gives a different icon for .PSD files than the actual application icon.
In simpler terms, I would like to mimic this behaviour but with my own icons and application:
Photoshop (the actual application):
Photoshop Document file:
I am working in C# and WPF. And I should also specify that the solution I'm looking for should be able to work in a scenario where I was to send my application to someone else to install on their computer; they should be able to see all the icons as described. I'd kindly request that in your answers you provide code examples, as I am not particularly familiar with working directly with the registry.
I should also specify that my application does have an icon, and this is currently what the custom filetype displays in Windows Explorer.

How to change desktop/folders Icons size programmatically C#

I'm developing a WPF that needs to make desktop icons and folder icons bigger while the WPF is active
and returns them to their previous state when closing the WPF
basically I want to be able to control the following options programmatically:
Folders icons :
desktop icons:
also how to change folder option to single click mode :
Folder icon settings are often per-folder and you will have a hard time forcing your preferences on them. You can probably find some descriptions of the registry locations and format if you search the internet for "shellbags" but this puts you in undocumented territory.
The desktop icon mode can probably be changed by undocumented/hacky means but you should just let the user do it.
You might be able to change the double-click mode by playing with fDoubleClickInWebView and SHGetSetSettings.

Where are the default icons of components in C# stored?

I will like to load the timer icon in main form icon, but can't find where it is stored.
So my question is: In which dll are icons of components stored (where is the timer icon stored)?
The icons you are referring to are embedded into the .NET Framework assemblies as resources. You can get various images and icons from here.

How to include windows right click menu in my application?

I have a desktop app which after taking input from the user displays a list of files and folder(using a ListBox).
I want that when the user right clicks on any item in the ListBox, the right click menu of windows explorer should display.
I know I will have to use P/Invoke for this, but I am unable to find any relevant information such as which dll I have to use or which function I have to call.
Can anybody help me with that?
So this question is very old but has no accepted answer. I dont think Visionstar understood the issue OP is having.
My understanding is that you have an application running, and you would like to add an option in the WINDOWS EXPLORER's right-click menu. Not in your own application's context menu.
I do not think you can achieve this within your own application, however, what you can do is add an item in the Windows explorer's context menu (nothing to do with your application, you can just do that in windows; see link below) that you can setup to call a little script you would make (literally a little batch file... but could be a .net app too). That little script can take care of warning you main application. By creating a text file, or json file in a hot folder, or some other mechanism you would have to come up with.
Adding an item in the windows' contextual menu:
How add context menu item to Windows Explorer for folders
If you need to deploy this to other PCs, you can make a add_menu.reg file to make it simpler. I'll let you Google that one, but I think it's as simpe as a right-click -> export key in your regedit.
You will need to code it yourself, there is no embedded way simply add a OS-Contextmenu to it,because you have programmed the listbox, so you have to append some contextmenu to the listitem-rightclicks
Here are examples/guidance for adding a context menu:
http://msdn.microsoft.com/en-us/library/aa984254%28v=vs.71%29.aspx
http://social.msdn.microsoft.com/Forums/windows/en-US/790cd8be-0ba8-4f10-95a8-c88f1023d6e7/how-can-i-create-a-rightclick-menu-i-c?forum=winforms

What methods are available in the WinAPI for accessing programs in the system tray?

What DLLs would have functions for accessing things in the System Tray? Do I even need the winapi, or are there classes already available in the Class Library for this? I'm hoping to find a way to emulate all the functionality of the system tray, i.e. the icons, the mouseover text, and the capability to display the context menu.
You can enumerate tray icons, retrieve tooltips, emulate single click, double and right click. See this article which explains how to do it with winapi: Shell Tray Info - Arrange your system tray icons
There is the Shell_NotifyIcon function to work with tray icons natively. With .NET there is NotifyIcon class you can use, which does the job.

Categories