示例#1
0
        static PIDLIST()
        {
            IntPtr ptrEmpty = Marshal.AllocCoTaskMem(4);

            Marshal.WriteInt32(ptrEmpty, 0);
            _empty = new PIDLIST(ptrEmpty);
        }
        public int CompareIDs(PIDLIST pidl1, PIDLIST pidl2, int lParam = 0)
        {
            HRESULT hr = Com.CompareIDs(lParam, pidl1, pidl2);

            hr.ThrowIfFailed();
            return(hr.Code);
        }
示例#3
0
        public int GetOverlayIconIndex(PIDLIST pidl)
        {
            int     overlayIndex = 0;
            HRESULT hr           = Com.GetOverlayIconIndex(pidl, ref overlayIndex);

            return(hr.IsSucceeded ? overlayIndex : ShellItem.NoIconIndex);
        }
        public T BindToObject <T> (PIDLIST pidl) where T : class
        {
            object  obj;
            HRESULT hr = Com.BindToObject(pidl, null, typeof(T).GUID, out obj);

            return(hr.IsSucceeded ? (T)obj : null);
        }
        public T BindToStorage <T> (PIDLIST pidl)
        {
            object obj;

            Com.BindToStorage(pidl, null, typeof(T).GUID, out obj);
            return((T)obj);
        }
        public PIDLIST SetNameOf(HWND hwnd, PIDLIST pidl, string displayName, SHGDN flags)
        {
            PIDLIST pidlOut;

            Com.SetNameOf(hwnd, pidl, displayName, flags, out pidlOut);
            return(pidlOut);
        }
        public string GetDisplayNameOf(PIDLIST pidl, SHGDN uFlags)
        {
            STRRET name;

            Com.GetDisplayNameOf(pidl, uFlags, out name);
            return(Native.StrRetToBuf(ref name, pidl));
        }
示例#8
0
        public int GetOverlayIndex(PIDLIST pidl, bool allowAsync = false)
        {
            int     overlayIndex = allowAsync ? OI.ASYNC : 0;
            HRESULT hr           = Com.GetOverlayIndex(pidl, ref overlayIndex);

            if (hr == HRESULT.E_PENDING)
            {
                return(ShellItem.AsyncIconIndex);
            }
            return(hr.IsSucceeded ? overlayIndex : ShellItem.NoIconIndex);
        }
        public int GetIconOf([In] PIDLIST pidl, [In] GILI flags)
        {
            int     iconIndex;
            HRESULT hr = Com.GetIconOf(pidl, flags, out iconIndex);

            if (hr == HRESULT.S_FALSE)
            {
                return(ShellItem.NoIconIndex);
            }
            hr.ThrowIfFailed();
            return(iconIndex);
        }
示例#10
0
        public override string ToString()
        {
            var sb = new StringBuilder();
            int i  = 0;

            for (PIDLIST pidl = this; !Native.ILIsEmpty(pidl); pidl = Native.ILNext(pidl))
            {
                byte[] data = new byte[pidl.Cb];
                Marshal.Copy(Handle, data, 2, pidl.Cb - 2);
                sb.AppendFormat("{0} ({1} bytes): {2} ({3})\n", i++, pidl.Cb,
                                BitConverter.ToString(data).Replace("-", ""),
                                Encoding.ASCII.GetString(data).Replace('\0', ' '));
            }
            return(sb.ToString());
        }
 public T GetUIObjectOf <T> (PIDLIST pidl)
 {
     return(GetUIObjectOf <T>(pidl, IntPtr.Zero));
 }
 public T GetUIObjectOf <T> (PIDLIST pidl, HWND hwnd)
 {
     return(GetUIObjectOf <T>(new[] { pidl }, hwnd));
 }
 public SFGAO GetAttributesOf(PIDLIST pidl, SFGAO attrs)
 {
     return(GetAttributesOf(new[] { pidl }, attrs));
 }