Note that there are some explanatory texts on larger screens.

plurals
  1. POIcon overlay in c#
    primarykey
    data
    text
    <p>I beg your pardon, if its a silly question. But I really need to know how can I use the code I am posting below. I have copied it from a form. I want to implement folder/file icon overlay. So while searching, I found the below code. </p> <pre><code>public sealed class ShellInterop { private ShellInterop() { } [DllImport("shell32.dll")] public static extern void SHChangeNotify(int eventID, uint flags, IntPtr item1, IntPtr item2); } [ComVisible(false)] [ComImport] [Guid("0C6C4200-C589-11D0-999A-00C04FD655E1")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IShellIconOverlayIdentifier { [PreserveSig] int IsMemberOf([MarshalAs(UnmanagedType.LPWStr)]string path, uint attributes); [PreserveSig] int GetOverlayInfo( IntPtr iconFileBuffer, int iconFileBufferSize, out int iconIndex, out uint flags); [PreserveSig] int GetPriority(out int priority); } [ComVisible(true)] [Guid("B8FA9E43-38E6-4654-8A13-FF905AD22CE5")] public class MyIconOverlay : IShellIconOverlayIdentifier { #region IShellIconOverlayIdentifier Members public int IsMemberOf(string path, uint attributes) { //Show everything with icon overlay return 0; // S_OK } public int GetOverlayInfo(IntPtr iconFileBuffer, int iconFileBufferSize, out int iconIndex, out uint flags) { System.Diagnostics.Debug.WriteLine(string.Format("GetOverlayInfo::{0}", iconFileBuffer)); System.Diagnostics.Debug.WriteLine(string.Format("GetOverlayInfo::{0}", iconFileBufferSize)); string fname = @"c:\NormalIcon.ico"; int bytesCount = System.Text.Encoding.Unicode.GetByteCount(fname); System.Diagnostics.Debug.WriteLine(string.Format("GetOverlayInfo::{0}", bytesCount)); byte[] bytes = System.Text.Encoding.Unicode.GetBytes(fname); if (bytes.Length + 2 &lt; iconFileBufferSize) { for (int i = 0; i &lt; bytes.Length; i++) { Marshal.WriteByte(iconFileBuffer, i, bytes[i]); } //write the "\0\0" Marshal.WriteByte(iconFileBuffer, bytes.Length, 0); Marshal.WriteByte(iconFileBuffer, bytes.Length + 1, 0); } iconIndex = 0; flags = 1; // ISIOI_ICONFILE return 0; // S_OK } public int GetPriority(out int priority) { priority = 0; // 0-100 (0 is highest priority) return 0; // S_OK } #endregion #region Registry [ComRegisterFunction] public static void Register(Type t) { RegistryKey rk = Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ShellIconOverlayIdentifiers\_" + t.Name); rk.SetValue(string.Empty, t.GUID.ToString("B").ToUpper()); rk.Close(); ShellInterop.SHChangeNotify(0x08000000, 0, IntPtr.Zero, IntPtr.Zero); } [ComUnregisterFunction] public static void Unregister(Type t) { Registry.LocalMachine.DeleteSubKeyTree(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ShellIconOverlayIdentifiers\_" + t.Name); ShellInterop.SHChangeNotify(0x08000000, 0, IntPtr.Zero, IntPtr.Zero); } #endregion } </code></pre> <p>Please if anyone can explain it to me. I have a situation, where I have to implement icon overlay for files and folder that a user creates under a special folder.</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload