2009-08-29 8 views

Répondre

4

Vous pouvez le relire via des appels P/Interop. Il va quelque chose comme ceci:

static Icon GetAppIcon() { 
    var fileName = Assembly.GetEntryAssembly().Location 
    System.IntPtr hLibrary = NativeMethods.LoadLibrary(fileName); 
    if (!hLibrary.Equals(System.IntPtr.Zero)) { 
     System.IntPtr hIcon = NativeMethods.LoadIcon(hLibrary, "#32512"); 
     if (!hIcon.Equals(System.IntPtr.Zero)) { 
      return Icon.FromHandle(hIcon); 
     } 
    } 
    return null; //no icon was retrieved 
} 

En outre, les signatures natives sont:

private static class NativeMethods { 
    [DllImport("user32.dll", CharSet = CharSet.Unicode)] 
    static extern internal IntPtr LoadIcon(IntPtr hInstance, string lpIconName); 

    [DllImport("kernel32.dll", CharSet = CharSet.Unicode)] 
    static extern internal IntPtr LoadLibrary(string lpFileName); 
} 
Questions connexes