public void Dispose() { if (_handler != null && Marshal.IsComObject(_handler)) { Marshal.ReleaseComObject(_handler); } _handler = null; }
private AssociatedHandler(IAssocHandler handler, IDataObject dao) { this.Handler = handler; this.Dao = dao; this.Name = handler.GetName(); this.DisplayName = handler.GetUIName(); }
private void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { _Handler = null; } } disposedValue = true; }
/// <summary> /// Refresh using the IAssocHandler /// </summary> /// <param name="handler"></param> internal void Refresh(IAssocHandler handler) { string pth = null; int idx = 0; _Handler = handler; Preferred = _Handler.IsRecommended() == HResult.Ok; string argppsz = ExePath; handler.GetName(out argppsz); ExePath = argppsz; if (File.Exists(ExePath) == false) { throw new SystemException("Program path not found"); } handler.GetUIName(out string strRet); UIName = strRet; handler.GetIconLocation(out pth, out idx); Icon = Resources.LoadLibraryIcon(pth, idx, IconSize); if (Icon is null) { int iix = (int)NativeShell.Shell_GetCachedImageIndex(pth, idx, 0U); switch (IconSize) { case StandardIcons.Icon256: Icon = Resources.GetFileIconFromIndex(iix, Resources.SystemIconSizes.Jumbo); break; case StandardIcons.Icon48: Icon = Resources.GetFileIconFromIndex(iix, Resources.SystemIconSizes.ExtraLarge); break; case StandardIcons.Icon32: Icon = Resources.GetFileIconFromIndex(iix, Resources.SystemIconSizes.Large); break; default: Icon = Resources.GetFileIconFromIndex(iix, Resources.SystemIconSizes.Small); break; } } }
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); }
/// <summary> /// Retrieves a UIHandler object base on the IAssocHandler from a cache or creates and returns a new one if it does not already exist. /// </summary> /// <param name="assoc">The IAssocHandler from which to build the new object.</param> /// <param name="ext">The Extension of the file type the IAssocHandler handles.</param> /// <returns>A new UIHandler object</returns> /// <remarks></remarks> internal UIHandler HandlerFromAssocHandler(IAssocHandler assoc, string ext) { UIHandler HandlerFromAssocHandlerRet = default; string exepath = null; assoc.GetName(out exepath); foreach (var u in _UICol) { if ((exepath ?? "") == (u.ExePath ?? "")) { u.AddExt(ext); return(u); } } HandlerFromAssocHandlerRet = new UIHandler(assoc, this); HandlerFromAssocHandlerRet.AddExt(ext); _UICol.Add(HandlerFromAssocHandlerRet); return(HandlerFromAssocHandlerRet); }
public bool MoveNext() { int outCelt = 0; IAssocHandler handler = null; _current = null; try { ((IInstance)_initializer).Get.Next(1, out handler, out outCelt); if (outCelt > 0) { _current = new AssocHandler(handler); return(true); } } catch { } return(false); }
internal UIHandler(IAssocHandler handler, AllSystemFileTypes parent) { _Parent = parent; Refresh(handler); }
internal AssocHandler(IAssocHandler handler) { _handler = handler; }