private DialogResult ShowVistaDialog(IWin32Window owner)
{
var dialog = new NativeMethods.FileOpenDialog();
try
{
SetDialogProperties(dialog);
int result = dialog.Show(owner == null ? IntPtr.Zero : owner.Handle);
if (result < 0)
{
if ((uint)result == (uint)NativeMethods.HRESULT.ERROR_CANCELLED)
return DialogResult.Cancel;
else
throw Marshal.GetExceptionForHR(result);
}
GetResult(dialog);
return DialogResult.OK;
}
finally
{
Marshal.FinalReleaseComObject(dialog);
}
}