Ejemplo n.º 1
0
        /// <summary>
        ///     Get the number of icon in the file
        /// </summary>
        /// <param name="location">Location of the EXE or DLL</param>
        /// <returns></returns>
        public static int CountAssociatedIcons(string location)
        {
            IntPtr large;
            IntPtr small;

            return(NativeInvokes.ExtractIconEx(location, -1, out large, out small, 0));
        }
Ejemplo n.º 2
0
        public MainPage()
        {
            this.InitializeComponent();

            System.Diagnostics.Trace.WriteLine("NativeInvokes.Init() calling!!!");
            NativeInvokes.Init();

            var ret = NativeInvokes.FT_Init_FreeType(out var lib);

            System.Diagnostics.Debug.WriteLine("arch: {2} - ret: {0}, lib: {1}", ret, lib, RuntimeInformation.ProcessArchitecture);
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     See: http://msdn.microsoft.com/en-us/library/windows/desktop/ms648069%28v=vs.85%29.aspx
        /// </summary>
        /// <typeparam name="TIcon"></typeparam>
        /// <param name="location">The file (EXE or DLL) to get the icon from</param>
        /// <param name="index">Index of the icon</param>
        /// <param name="useLargeIcon">true if the large icon is wanted</param>
        /// <returns>Icon</returns>
        public static TIcon ExtractAssociatedIcon <TIcon>(string location, int index = 0, bool useLargeIcon = true) where TIcon : class
        {
            IntPtr large;
            IntPtr small;

            NativeInvokes.ExtractIconEx(location, index, out large, out small, 1);
            TIcon returnIcon = null;

            try
            {
                if (useLargeIcon && !IntPtr.Zero.Equals(large))
                {
                    returnIcon = IconHandleTo <TIcon>(large);
                }
                else if (!IntPtr.Zero.Equals(small))
                {
                    returnIcon = IconHandleTo <TIcon>(small);
                }
                else if (!IntPtr.Zero.Equals(large))
                {
                    returnIcon = IconHandleTo <TIcon>(large);
                }
            }
            finally
            {
                if (!IntPtr.Zero.Equals(small))
                {
                    User32Api.DestroyIcon(small);
                }
                if (!IntPtr.Zero.Equals(large))
                {
                    User32Api.DestroyIcon(large);
                }
            }
            return(returnIcon);
        }