BExplorer.Shell.Win32Api.SHGetFileInfo C# (CSharp) Method

SHGetFileInfo() private method

private SHGetFileInfo ( IntPtr pszPath, FileAttributes attr, SHFILEINFO &psfi, int cbSizeFileInfo, SHGetFileInfoOptions uFlags ) : IntPtr
pszPath System.IntPtr
attr FileAttributes
psfi BExplorer.Shell.Interop.SHFILEINFO
cbSizeFileInfo int
uFlags SHGetFileInfoOptions
return System.IntPtr
		public static extern IntPtr SHGetFileInfo(IntPtr pszPath, FileAttributes attr, ref SHFILEINFO psfi, int cbSizeFileInfo, SHGetFileInfoOptions uFlags);
		//Note:	Date: 8/28/2014	User: Aaron Campf	Message: Replaces below code with above code

Usage Example

Example #1
0
        public int GetIconIndex(IntPtr path)
        {
            var    options  = SHGetFileInfoOptions.SysIconIndex | SHGetFileInfoOptions.Icon | SHGetFileInfoOptions.Pidl;
            var    shfi     = new SHFILEINFO();
            var    shfiSize = Marshal.SizeOf(shfi.GetType());
            IntPtr retVal   = Win32Api.SHGetFileInfo(path, FileAttributes.None, ref shfi, shfiSize, options);

            if (shfi.hIcon != IntPtr.Zero)
            {
                Win32Api.DestroyIcon(shfi.hIcon);
            }

            if (retVal.Equals(IntPtr.Zero))
            {
                //throw new Win32Exception(Marshal.GetLastWin32Error());

                return(0);
            }
            else
            {
                /* brakes stack on optimized build
                 * int idx = shfi.iIcon & 0xFFFFFF;
                 * int iOverlay = shfi.iIcon >> 24;
                 * overlayIndex = iOverlay;
                 * return idx;
                 */

                return(shfi.iIcon & 0xFFFFFF);
            }
        }
All Usage Examples Of BExplorer.Shell.Win32Api::SHGetFileInfo