FRBDK/MasterInstaller/MasterInstallerWpf/Managers/FileIcon.cs
/// <summary>
///  Gets the information for the specified 
///  file name and flags.
/// </summary>
Gets the information for the specified
file name and flags.
Gets the information for the specified file name and flags .
public void GetInfo()
        {
            fileIcon = null;
            typeName = "";
            displayName = "";
            SHFILEINFO shfi = new SHFILEINFO();
            uint shfiSize = (uint)Marshal.SizeOf(shfi.GetType());
            int ret = SHGetFileInfo(
               fileName, 0, ref shfi, shfiSize, (uint)(flags));
            if (ret != 0)
            {
                if (shfi.hIcon != IntPtr.Zero)
                {
                    fileIcon = System.Drawing.Icon.FromHandle(shfi.hIcon);
                }
                typeName = shfi.szTypeName;
                displayName = shfi.szDisplayName;
            }
            else
            {
                int err = GetLastError();
                Console.WriteLine("Error {0}", err);
                string txtS = new string('\0', 256);
                int len = FormatMessage(
                   FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
                   IntPtr.Zero, err, 0, txtS, 256, 0);
                Console.WriteLine("Len {0} text {1}", len, txtS);
            }
        }
public void GetInfo ( ) { fileIcon = null ; typeName = " " ; displayName = " " ; SHFILEINFO shfi = new SHFILEINFO ( ) ; uint shfiSize = ( uint ) Marshal . SizeOf ( shfi . GetType ( ) ) ; int ret = SHGetFileInfo ( fileName , 0 , ref shfi , shfiSize , ( uint ) ( flags ) ) ; if ( ret != 0 ) { if ( shfi . hIcon != IntPtr . Zero ) { fileIcon = System . Drawing . Icon . FromHandle ( shfi . hIcon ) ; } typeName = shfi . szTypeName ; displayName = shfi . szDisplayName ; } else { int err = GetLastError ( ) ; Console . WriteLine ( " " , err ) ; string txtS = new string ( ' \0 ' , 256 ) ; int len = FormatMessage ( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS , IntPtr . Zero , err , 0 , txtS , 256 , 0 ) ; Console . WriteLine ( " " , len , txtS ) ; } }
Gets the information for the specified
file name and flags.
Gets the information for the specified file name and flags .
// Now owned by the GDI+ object //DestroyIcon(shfi.hIcon); // throw exception