Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yeah, it's pretty annoying. But the problem with the proposed answer of Icon.ExtractAssociatedIcon is that it will retrieve the 32x32 icon, and then downsample to a 16x16 icon in your forms window or on the taskbar, which will look terrible unless your 32x32 icon is very cleverly constructed.</p> <p>The way I'm doing it is with interop (put the first line in your form constructor):</p> <pre><code>this.Icon = ExtractSmallIconFromLibrary(Application.ExecutablePath); ... public static Icon ExtractSmallIconFromLibrary(string file) { IntPtr[] reficon = new IntPtr[1]; int nextracted = ExtractIconEx(file, 0, null, reficon, 1); if (nextracted &lt; 1) return null; Icon unmanaged_icon = Icon.FromHandle(reficon[0]); Icon icon = (Icon)unmanaged_icon.Clone(); DestroyIcon(unmanaged_icon.Handle); return icon; } [DllImport("Shell32", CharSet = CharSet.Auto)] extern static int ExtractIconEx( [MarshalAs(UnmanagedType.LPTStr)] string lpszFile, int nIconIndex, IntPtr[] phIconLarge, IntPtr[] phIconSmall, int nIcons ); [DllImport("user32.dll", CharSet = CharSet.Auto)] extern static bool DestroyIcon(IntPtr handle); </code></pre> <p>But this isn't great, either, since you <em>do</em> want the 32x32 icon for things like the Alt-Tab icon list. So you really need to extract the <em>entire</em> icon, which is a bigger job. Maybe there's a straightforward way to combine the two icons into one. Or you can do like this <a href="http://www.codeproject.com/KB/dialog/AssigningDefaultIcon.aspx" rel="noreferrer">codeproject</a> program, which extracts the whole icon in the first place with a huge pile of code.</p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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