private DialogResult ShowDialogInternal(ref BrowseInfo bi) { bi.title = title; bi.displayname = new string('\0', 260); bi.callback = BrowseCallback; bi.flags = (int)BrowseFlags; //Free any old pidls if (pidlReturned != IntPtr.Zero) { NativeMethods.SHMemFree(pidlReturned); } var ret = (pidlReturned = NativeMethods.SHBrowseForFolder(ref bi)) != IntPtr.Zero; if (ret) { FolderDisplayName = bi.displayname; } //Reset the handle handle = IntPtr.Zero; return(ret ? DialogResult.OK : DialogResult.Cancel); }
/// <summary> /// Shows the dialog /// </summary> /// <param name="owner">The window to use as the owner</param> /// <returns></returns> public DialogResult ShowDialog(IWin32Window owner) { if (handle != IntPtr.Zero) { throw new InvalidOperationException(); } var bi = new BrowseInfo(); if (owner != null) { bi.hwndOwner = owner.Handle; } return(ShowDialogInternal(ref bi)); }
internal static extern IntPtr SHBrowseForFolder(ref BrowseInfo bi);