public static bool GetShellFolder(IntPtr pIDLFolder, out IShellFolder shellFolder) { shellFolder = null; if (PInvoke.ILGetSize(pIDLFolder) == 2) { return(0 == PInvoke.SHGetDesktopFolder(out shellFolder)); } IShellFolder ppshf = null; Guid riid = ExplorerGUIDs.IID_IShellFolder; try { if (PInvoke.SHGetDesktopFolder(out ppshf) == 0) { return(0 == ppshf.BindToObject(pIDLFolder, IntPtr.Zero, ref riid, out shellFolder)); } } catch { } finally { if (ppshf != null) { Marshal.ReleaseComObject(ppshf); } } return(false); }
public static byte[] GetIDLData(IntPtr pIDL) { uint num = PInvoke.ILGetSize(pIDL); if (num != 0) { byte[] destination = new byte[num]; Marshal.Copy(pIDL, destination, 0, (int)num); return(destination); } return(null); }