Example #1
0
        int IExtractIcon.GetIconLocation(ExtractIconOptions uFlags, IntPtr szIconFile, uint cchMax, out int piIndex, out ExtractIconFlags pwFlags)
        {
            piIndex = -1;
            pwFlags = ExtractIconFlags.None;

            icon = folderObj.GetIcon((uFlags & ExtractIconOptions.OpenIcon) == ExtractIconOptions.OpenIcon);

            if (icon is ShellIcon.FromFile)
            {
                string filename = (icon as ShellIcon.FromFile).Filename;
                byte[] data     = new byte[cchMax * 2];
                Encoding.Unicode.GetBytes(filename, 0, filename.Length, data, 0);
                Marshal.Copy(data, 0, szIconFile, data.Length);

                piIndex = (icon as ShellIcon.FromFile).Index;
                pwFlags = icon.Flags;
                return(0);
            }
            else if (icon is ShellIcon.FromIcon)
            {
                pwFlags = ExtractIconFlags.NotFilename | ExtractIconFlags.DontCache;//icon.Flags;
                return(0);
            }
            else if (icon == null)
            {
                return(1);                      // use default icon
            }

            Trace.Fail("Unreachable code");
            return(0);
        }
 /// <summary>
 /// Get the icon location
 /// </summary>
 /// <param name="uFlags"></param>
 /// <param name="szIconFile"></param>
 /// <param name="cchMax"></param>
 /// <param name="piIndex"></param>
 /// <param name="pwFlags"></param>
 /// <returns></returns>
 public uint GetIconLocation(ExtractIconOptions uFlags, IntPtr szIconFile, uint cchMax, out int piIndex, out ExtractIconFlags pwFlags)
 {
     piIndex    = -1;
     szIconFile = IntPtr.Zero;
     try {
         pwFlags = ExtractIconFlags.NotFilename | ExtractIconFlags.PerInstance | ExtractIconFlags.DontCache;
         return(((uFlags & ExtractIconOptions.Async) != 0) ? E_PENDING : S_OK);
     } catch (Exception ex) {
         //Log.Error ( ex.Message, ex );
         pwFlags = ExtractIconFlags.None;
         return(S_FALSE);
     }
 }
Example #3
0
        private int GetIconLocation(ExtractIconOptions uFlags, out int piIndex, out ExtractIconFlags pwFlags)
        {
            //No need for an index
            piIndex = 0;

            //Check ShellExtLib.cs for more info on these flags
            pwFlags = ExtractIconFlags.NotFilename | ExtractIconFlags.PerInstance | ExtractIconFlags.DontCache;

            //Return the name for the icon cache
            //szIconFile = Marshal.StringToHGlobalAuto(currentFile);

            //I got this under control!
            return(WinError.S_OK);
        }
Example #4
0
        int IExtractIcon.GetIconLocation(ExtractIconOptions uFlags, IntPtr szIconFile, uint cchMax, out int piIndex, out ExtractIconFlags pwFlags)
        {
            piIndex = -1;

            try
            {
                FileInfo f = new FileInfo(szFileName);
                lngFileSize = f.Length;
                pwFlags     = ExtractIconFlags.DontCache | ExtractIconFlags.NotFilename;

                return(S_OK);
            }
            catch { }

            pwFlags = ExtractIconFlags.None;
            return(S_FALSE);
        }
Example #5
0
 public uint GetIconLocation(ExtractIconOptions uFlags, IntPtr szIconFile, uint cchMax, out int piIndex, out ExtractIconFlags pwFlags)
 {
     piIndex = 0;
     pwFlags = ExtractIconFlags.NotFilename | ExtractIconFlags.PerInstance | ExtractIconFlags.DontCache;
     if (sFileName.Length < cchMax)
     {
         szIconFile = Marshal.StringToHGlobalAuto(sFileName); // return the name for icon cache
     }
     else
     {
         szIconFile = IntPtr.Zero;
         pwFlags = pwFlags | ExtractIconFlags.DontCache;
     }
     NativeMethods.Log("GetIconLocation: pwFlags = " + pwFlags.ToString());
     NativeMethods.Log("GetIconLocation: szIconFile = " + Marshal.PtrToStringAuto(szIconFile));
     NativeMethods.Log("GetIconLocation: piIndex = " + piIndex.ToString());
     NativeMethods.Log("GetIconLocation: ExtractIconOptions.Async = " + uFlags.ToString());
     return ((uFlags & ExtractIconOptions.Async) != 0) ? WinError.E_PENDING : WinError.S_OK;
 }
Example #6
0
 public uint GetIconLocation(ExtractIconOptions uFlags, IntPtr szIconFile, uint cchMax, out int piIndex, out ExtractIconFlags pwFlags)
 {
     piIndex = 0;
     pwFlags = ExtractIconFlags.NotFilename | ExtractIconFlags.PerInstance | ExtractIconFlags.DontCache;
     if (sFileName.Length < cchMax)
     {
         szIconFile = Marshal.StringToHGlobalAuto(sFileName); // return the name for icon cache
     }
     else
     {
         szIconFile = IntPtr.Zero;
         pwFlags    = pwFlags | ExtractIconFlags.DontCache;
     }
     NativeMethods.Log("GetIconLocation: pwFlags = " + pwFlags.ToString());
     NativeMethods.Log("GetIconLocation: szIconFile = " + Marshal.PtrToStringAuto(szIconFile));
     NativeMethods.Log("GetIconLocation: piIndex = " + piIndex.ToString());
     NativeMethods.Log("GetIconLocation: ExtractIconOptions.Async = " + uFlags.ToString());
     return(((uFlags & ExtractIconOptions.Async) != 0) ? WinError.E_PENDING : WinError.S_OK);
 }
Example #7
0
        int IExtractIcon.GetIconLocation(ExtractIconOptions uFlags, IntPtr szIconFile, uint cchMax, out int piIndex, out ExtractIconFlags pwFlags)
        {
            piIndex = -1;

            try
            {
                FileInfo f = new FileInfo(szFileName);
                lngFileSize = f.Length;
                pwFlags = ExtractIconFlags.DontCache | ExtractIconFlags.NotFilename;

                return S_OK;
            }
            catch { }

            pwFlags = ExtractIconFlags.None;
            return S_FALSE;
        }
 /// <summary>
 /// Get the icon location
 /// </summary>
 /// <param name="uFlags"></param>
 /// <param name="szIconFile"></param>
 /// <param name="cchMax"></param>
 /// <param name="piIndex"></param>
 /// <param name="pwFlags"></param>
 /// <returns></returns>
 public uint GetIconLocation( ExtractIconOptions uFlags, IntPtr szIconFile, uint cchMax, out int piIndex, out ExtractIconFlags pwFlags )
 {
     piIndex = -1;
     szIconFile = IntPtr.Zero;
     try {
         pwFlags = ExtractIconFlags.NotFilename | ExtractIconFlags.PerInstance | ExtractIconFlags.DontCache;
         return ( ( uFlags & ExtractIconOptions.Async ) != 0 ) ? E_PENDING : S_OK;
     } catch ( Exception ex ) {
         //Log.Error ( ex.Message, ex );
         pwFlags = ExtractIconFlags.None;
         return S_FALSE;
     }
 }
Example #9
0
 int IExtractIconW.GetIconLocation(ExtractIconOptions uFlags, StringBuilder szIconFile, int cchMax, out int piIndex, out ExtractIconFlags pwFlags)
 {
     return(GetIconLocation(uFlags, out piIndex, out pwFlags));
 }