Beispiel #1
0
        public static ShellFileType GetExeType(string file)
        {
            const uint shgfiExetype = 0x000002000;

            var type = ShellFileType.FileNotFound;

            if (!File.Exists(file))
            {
                return(type);
            }
            ShFileinfo shinfo = new ShFileinfo();
            IntPtr     ptr    = Shell32.SHGetFileInfo(file, 128, ref shinfo, (uint)Marshal.SizeOf(shinfo), shgfiExetype);
            int        wparam = ptr.ToInt32();
            int        loWord = wparam & 0xffff;
            int        hiWord = wparam >> 16;

            type = ShellFileType.Unknown;

            if (wparam != 0)
            {
                if (hiWord == 0x0000 && loWord == 0x5a4d)
                {
                    type = ShellFileType.Dos;
                }
                else if (hiWord == 0x0000 && loWord == 0x4550)
                {
                    type = ShellFileType.Console;
                }
                else if (hiWord != 0x0000 && (loWord == 0x454E || loWord == 0x4550 || loWord == 0x454C))
                {
                    type = ShellFileType.Windows;
                }
            }
            return(type);
        }
Beispiel #2
0
 internal static extern IntPtr SHGetFileInfo(
     string pszPath,
     uint dwFileAttributes,
     ref ShFileinfo psfi,
     uint cbSizeFileInfo,
     uint uFlags);
Beispiel #3
0
 public static extern IntPtr SHGetFileInfo(string pszPath, uint dwFileAttributes, ref ShFileinfo psfi, uint cbSizeFileInfo, uint uFlags);