Exemple #1
0
        private static string FileExtentionInfo(AssocStr assocStr, string doctype)
        {
            IntPtr pcchOut = IntPtr.Zero;

            if (SafeNativeMethods.AssocQueryString(AssocF.Verify, assocStr, doctype, null, null, ref pcchOut) != 1)
            {
                return(null);
            }

            StringBuilder pszOut = new StringBuilder((int)pcchOut);

            if (SafeNativeMethods.AssocQueryString(AssocF.Verify, assocStr, doctype, null, pszOut, ref pcchOut) != 0)
            {
                return(null);
            }

            return(pszOut.ToString());
        }
Exemple #2
0
        private static ImageSource GetIconInternal(string extension)
        {
            if (string.IsNullOrEmpty(extension))
            {
                return(FileIcon);
            }

            string path;

            try
            {
                path = SafeNativeMethods.AssocQueryString(SafeNativeMethods.AssocStr.DefaultIcon, extension);
            }
            catch (InvalidOperationException)
            {
                return(FileIcon);
            }

            return(SafeNativeMethods.ExtractAssociatedIcon(path));
        }