BExplorer.Shell.Interop.VistaBridge.ShellItemImpl.GetIShellFolder C# (CSharp) Method

GetIShellFolder() private method

private GetIShellFolder ( ) : IShellFolder
return IShellFolder
		private IShellFolder GetIShellFolder() {
			IShellFolder desktop = Shell32.SHGetDesktopFolder();
			IntPtr desktopPidl;

			Shell32.SHGetSpecialFolderLocation(IntPtr.Zero, CSIDL.DESKTOP, out desktopPidl); ;

			if (Shell32.ILIsEqual(Pidl, desktopPidl)) {
				return desktop;
			}
			else {
				IntPtr result;
				desktop.BindToObject(Pidl, IntPtr.Zero, typeof(IShellFolder).GUID, out result);
				return (IShellFolder)Marshal.GetTypedObjectForIUnknown(result, typeof(IShellFolder));
			}
		}
	}

Usage Example

Example #1
0
        public int Compare(IShellItem psi, SICHINT hint)
        {
            var           other       = (ShellItemImpl)psi;
            ShellItemImpl myParent    = GetParent();
            ShellItemImpl theirParent = other.GetParent();

            if (Shell32.ILIsEqual(myParent.Pidl, theirParent.Pidl))
            {
                return(myParent.GetIShellFolder().CompareIDs((SHCIDS)hint, Shell32.ILFindLastID(Pidl), Shell32.ILFindLastID(other.Pidl)));
            }
            else
            {
                return(1);
            }
        }