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); }
public unsafe override string ToString() { if (_pointer == IntPtr.Zero) { throw new ObjectDisposedException(nameof(ReturnString)); } STRRET *s = (STRRET *)_pointer.ToPointer(); return((s->uType) switch { STRRET.STRRET_TYPE.STRRET_WSTR => new string(s->Data.pOleStr), STRRET.STRRET_TYPE.STRRET_CSTR => throw new NotSupportedException(), STRRET.STRRET_TYPE.STRRET_OFFSET => throw new NotSupportedException(), _ => throw new InvalidOperationException() });
public unsafe void Dispose() { if (_pointer == IntPtr.Zero) { throw new ObjectDisposedException(nameof(ReturnString)); } STRRET *s = (STRRET *)_pointer.ToPointer(); if (s->uType == STRRET.STRRET_TYPE.STRRET_WSTR) { Marshal.FreeCoTaskMem((IntPtr)s->Data.pOleStr); s->uType = STRRET.STRRET_TYPE.STRRET_CSTR; s->Data.pOleStr = null; } _pointer = IntPtr.Zero; }
public HRESULT GetDisplayNameOf([NativeTypeName("LPCITEMIDLIST")] ITEMIDLIST *pidl, [NativeTypeName("SHGDNF")] uint uFlags, STRRET *pName) { return(((delegate * unmanaged <IShellFolder2 *, ITEMIDLIST *, uint, STRRET *, int>)(lpVtbl[11]))((IShellFolder2 *)Unsafe.AsPointer(ref this), pidl, uFlags, pName)); }