示例#1
0
 public void Dispose()
 {
     if (_enumHandler != null && Marshal.IsComObject(_enumHandler))
     {
         Marshal.ReleaseComObject(_enumHandler);
     }
     _enumHandler = null;
 }
示例#2
0
        public static IAssocHandler[] EnumFileHandlers(string fileExtension, bool flush = false)
        {
            var assoc = flush ? null : FindInCache(fileExtension);

            if (assoc is object)
            {
                return(assoc);
            }

            if (lAssoc.Count > 0)
            {
                lAssoc.Clear();
            }

            IAssocHandler      h        = null;
            IEnumAssocHandlers handlers = null;

            uint cret;

            try
            {
                NativeShell.SHAssocEnumHandlers(fileExtension, ASSOC_FILTER.RECOMMENDED, out handlers);
            }
            catch
            {
                return(null);
            }

            do
            {
                handlers.Next(1U, out h, out cret);
                if (h is object)
                {
                    lAssoc.Add(h);
                }
            }while (cret > 0L);

            assoc = lAssoc.ToArray();
            AddToCache(fileExtension, assoc);

            return(assoc);
        }
示例#3
0
 public static extern long SHAssocEnumHandlers([In, MarshalAs(UnmanagedType.LPWStr)] string pszExtra, [In] ASSOC_FILTER afFilter, [Out, MarshalAs(UnmanagedType.Interface)] out IEnumAssocHandlers ppEnumHandler);
示例#4
0
 public static extern HResult SHAssocEnumHandlers([MarshalAs(UnmanagedType.LPWStr)][In] string pszExtra, [In] ASSOC_FILTER afFilter, out IEnumAssocHandlers ppEnumHandler);
示例#5
0
 internal static extern Int32 SHAssocEnumHandlersForProtocolByApplication(
     [In, MarshalAs(UnmanagedType.LPWStr)] string protocol,
     ref Guid riid,
     [Out, MarshalAs(UnmanagedType.Interface)] out IEnumAssocHandlers ppEnumHandler);