Ejemplo n.º 1
0
        public unsafe string ToString(ItemIdList pidl)
        {
            if (_pointer == IntPtr.Zero)
            {
                throw new ObjectDisposedException(nameof(ReturnString));
            }

            string  result = null;
            STRRET *s      = (STRRET *)_pointer.ToPointer();

            switch (s->uType)
            {
            case STRRET.STRRET_TYPE.STRRET_WSTR:
                result = new string(s->Data.pOleStr);
                break;

            case STRRET.STRRET_TYPE.STRRET_CSTR:
                // https://docs.microsoft.com/en-us/windows/desktop/api/shlwapi/nf-shlwapi-shansitounicode
                throw new NotSupportedException();

            case STRRET.STRRET_TYPE.STRRET_OFFSET:
                // https://docs.microsoft.com/en-us/windows/desktop/api/shlwapi/nf-shlwapi-shansitounicode
                throw new NotSupportedException();

            default:
                throw new InvalidOperationException();
            }

            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get the name for a given Shell item ID.
        /// </summary>
        public static string GetNameFromId(ItemIdList id, SIGDN form = SIGDN.NORMALDISPLAY)
        {
            HRESULT hr = Imports.SHGetNameFromIDList(id, form, out string name);

            if (hr != HRESULT.S_OK)
            {
                throw Errors.GetIoExceptionForHResult(hr);
            }

            return(name);
        }
Ejemplo n.º 3
0
 public static extern HResult SHGetNameFromIDList(
     ItemIdList pidl,
     ShellItemDisplayNames sigdnName,
     out string ppszName);
Ejemplo n.º 4
0
 public static extern HResult SHGetKnownFolderIDList(
     ref Guid rfid,
     KnownFolderFlags dwFlags,
     SafeHandle hToken,
     out ItemIdList ppidl);
Ejemplo n.º 5
0
 public unsafe static extern bool SHGetPathFromIDListEx(
     ItemIdList pidl,
     char *pszPath,
     uint cchPath,
     uint uOpts);
Ejemplo n.º 6
0
 /// <summary>
 ///  Get the name for a given Shell item ID.
 /// </summary>
 public static string GetNameFromId(ItemIdList id, ShellItemDisplayNames form = ShellItemDisplayNames.NormalDisplay)
 {
     Imports.SHGetNameFromIDList(id, form, out string name).ThrowIfFailed();
     return(name);
 }
Ejemplo n.º 7
0
 public static extern HRESULT SHGetNameFromIDList(
     ItemIdList pidl,
     SIGDN sigdnName,
     out string ppszName);
Ejemplo n.º 8
0
 public static extern HRESULT SHGetKnownFolderIDList(
     [MarshalAs(UnmanagedType.LPStruct)] Guid rfid,
     KNOWN_FOLDER_FLAG dwFlags,
     SafeHandle hToken,
     out ItemIdList ppidl);