Beispiel #1
0
        private static IShellItem CreateShellItemFromParsingName(string path)
        {
            object nativeShellItem;
            Guid   guid = new Guid("43826D1E-E718-42EE-BC55-A1E261C37BFE"); //IID_IShellItem

            int hr = CommonDialogNativeMethods.SHCreateItemFromParsingName(path, IntPtr.Zero, ref guid, out nativeShellItem);

            if (nativeShellItem == null || hr < 0)
            {
                throw new ExternalException("Shell item could not be created.", Marshal.GetExceptionForHR(hr));
            }

            return((IShellItem)nativeShellItem);
        }
Beispiel #2
0
        public CommonDialogResult ShowDialog(IntPtr hwndOwner)
        {
            if (hwndOwner == IntPtr.Zero)
            {
                hwndOwner = CommonDialogNativeMethods.GetActiveWindow();
            }

            if (hwndOwner == IntPtr.Zero)
            {
                throw new InvalidOperationException("Owner handler is not set and cannot be determined!");
            }

            if (IsVistaOrLater)
            {
                return(RunVistaNativeDialog(hwndOwner));
            }
            else
            {
                return(RunLegacyDialog(hwndOwner));
            }
        }