Beispiel #1
0
        internal static ImageSource LoadIcon(SafeModuleHandle module, string resourceIdentifier, int preferredWidth = 0, int preferredHeight = 0)
        {
            if (module == null)
            {
                return((ImageSource)null);
            }
            IntPtr handle = NativeMethods.LoadIcon(module, resourceIdentifier);

            if (handle != IntPtr.Zero)
            {
                Icon original = Icon.FromHandle(handle);
                if (original != null)
                {
                    if (preferredHeight != 0 && preferredWidth != 0)
                    {
                        original = new Icon(original, preferredWidth, preferredHeight);
                    }
                    return((ImageSource)Imaging.CreateBitmapSourceFromHIcon(original.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()));
                }
            }
            return((ImageSource)null);
        }
Beispiel #2
0
 internal static extern bool FreeLibrary(SafeModuleHandle hModule);
Beispiel #3
0
 private static extern IntPtr LoadIcon(SafeModuleHandle hInstance, string lpIconName);
Beispiel #4
0
 private static extern int LoadString(SafeModuleHandle hInstance, uint uID, out IntPtr lpBuffer, int nBufferMax);