コード例 #1
0
        private static string GetDisplayNameImpl(IShellItem shellItem, ShellNativeMethods.ShellItemDesignNameOptions shellItemDesignNameOptions)
        {
            if (shellItem == null)
            {
                return(null);
            }

            string path = null;

            IntPtr  pszPath = IntPtr.Zero;
            HResult hr      = shellItem.GetDisplayName(shellItemDesignNameOptions, out pszPath);

            if (hr != HResult.Ok && hr != HResult.InvalidArguments)
            {
                throw new ShellException(LocalizedMessages.ShellHelperGetParsingNameFailed, hr);
            }

            if (pszPath != IntPtr.Zero)
            {
                path = Marshal.PtrToStringAuto(pszPath);
                Marshal.FreeCoTaskMem(pszPath);
                pszPath = IntPtr.Zero;
            }

            return(path);
        }
コード例 #2
0
 public static string GetDisplayName(this IShellItem shellItem, ShellNativeMethods.ShellItemDesignNameOptions shellItemDesignNameOptions)
 {
     return(GetDisplayNameImpl(shellItem, shellItemDesignNameOptions));
 }