mirror of https://github.com/dahall/Vanara.git
Fixed un-blittable structures
parent
da8b40b1b9
commit
45a356f601
|
@ -727,6 +727,22 @@ namespace Vanara.PInvoke
|
||||||
FOLDERID_Windows,
|
FOLDERID_Windows,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>Frees the allocated fields in the result from IKnownFolder::GetFolderDefinition.</summary>
|
||||||
|
/// <param name="pKFD">
|
||||||
|
/// <para>Type: <c>KNOWNFOLDER_DEFINITION*</c></para>
|
||||||
|
/// <para>A pointer to a KNOWNFOLDER_DEFINITION structure that contains information about the given known folder.</para>
|
||||||
|
/// </param>
|
||||||
|
/// <returns>This function does not return a value.</returns>
|
||||||
|
/// <remarks>This is an inline helper function that calls CoTaskMemFree on the fields in the structure that need to be freed. Its implementation can be seen in the header file.</remarks>
|
||||||
|
// https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nf-shobjidl_core-freeknownfolderdefinitionfields
|
||||||
|
// void FreeKnownFolderDefinitionFields( KNOWNFOLDER_DEFINITION *pKFD );
|
||||||
|
[PInvokeData("shobjidl_core.h", MSDNShortId = "0ad17dd3-e612-403a-b8c3-e93d5f259c1f")]
|
||||||
|
public static void FreeKnownFolderDefinitionFields(in KNOWNFOLDER_DEFINITION pKFD)
|
||||||
|
{
|
||||||
|
foreach (var fi in pKFD.GetType().GetFields().Where(f => f.FieldType == typeof(StrPtrUni)))
|
||||||
|
Marshal.FreeCoTaskMem((IntPtr)fi.GetValue(pKFD));
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Exposes methods that allow an application to retrieve information about a known folder's category, type, GUID, pointer to an item
|
/// Exposes methods that allow an application to retrieve information about a known folder's category, type, GUID, pointer to an item
|
||||||
/// identifier list (PIDL) value, redirection capabilities, and definition. It provides a method for the retrieval of a known folder's
|
/// identifier list (PIDL) value, redirection capabilities, and definition. It provides a method for the retrieval of a known folder's
|
||||||
|
@ -975,13 +991,13 @@ namespace Vanara.PInvoke
|
||||||
/// settings. This name is meant to be a unique, human-readable name. Third parties are recommended to follow the format
|
/// settings. This name is meant to be a unique, human-readable name. Third parties are recommended to follow the format
|
||||||
/// Company.Application.Name. The name given here should not be confused with the display name.
|
/// Company.Application.Name. The name given here should not be confused with the display name.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoTaskMemStringMarshaler))] public string pszName;
|
public StrPtrUni pszName;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A pointer to a short description of the known folder, stored as a null-terminated Unicode string. This description should
|
/// A pointer to a short description of the known folder, stored as a null-terminated Unicode string. This description should
|
||||||
/// include the folder's purpose and usage.
|
/// include the folder's purpose and usage.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoTaskMemStringMarshaler))] public string pszDescription;
|
public StrPtrUni pszDescription;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A KNOWNFOLDERID value that names another known folder to serve as the parent folder. Applies to common and per-user folders
|
/// A KNOWNFOLDERID value that names another known folder to serve as the parent folder. Applies to common and per-user folders
|
||||||
|
@ -995,13 +1011,13 @@ namespace Vanara.PInvoke
|
||||||
/// refers to the physical file system path, and is not localized. Applies to common and per-user folders only. See Remarks for
|
/// refers to the physical file system path, and is not localized. Applies to common and per-user folders only. See Remarks for
|
||||||
/// more details.
|
/// more details.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoTaskMemStringMarshaler))] public string pszRelativePath;
|
public StrPtrUni pszRelativePath;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A pointer to the Shell namespace folder path of the folder, stored as a null-terminated Unicode string. Applies to virtual
|
/// A pointer to the Shell namespace folder path of the folder, stored as a null-terminated Unicode string. Applies to virtual
|
||||||
/// folders only. For example, Control Panel has a parsing name of ::%CLSID_MyComputer%\::%CLSID_ControlPanel%.
|
/// folders only. For example, Control Panel has a parsing name of ::%CLSID_MyComputer%\::%CLSID_ControlPanel%.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoTaskMemStringMarshaler))] public string pszParsingName;
|
public StrPtrUni pszParsingName;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Optional. A pointer to the default tooltip resource used for this known folder when it is created. This is a null-terminated
|
/// Optional. A pointer to the default tooltip resource used for this known folder when it is created. This is a null-terminated
|
||||||
|
@ -1013,7 +1029,7 @@ namespace Vanara.PInvoke
|
||||||
/// </para>
|
/// </para>
|
||||||
/// <para>This information is not required for virtual folders.</para>
|
/// <para>This information is not required for virtual folders.</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoTaskMemStringMarshaler))] public string pszTooltip;
|
public StrPtrUni pszTooltip;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Optional. A pointer to the default localized name resource used when the folder is created. This is a null-terminated Unicode
|
/// Optional. A pointer to the default localized name resource used when the folder is created. This is a null-terminated Unicode
|
||||||
|
@ -1025,7 +1041,7 @@ namespace Vanara.PInvoke
|
||||||
/// </para>
|
/// </para>
|
||||||
/// <para>This information is not required for virtual folders.</para>
|
/// <para>This information is not required for virtual folders.</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoTaskMemStringMarshaler))] public string pszLocalizedName;
|
public StrPtrUni pszLocalizedName;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Optional. A pointer to the default icon resource used when the folder is created. This is a null-terminated Unicode string in
|
/// Optional. A pointer to the default icon resource used when the folder is created. This is a null-terminated Unicode string in
|
||||||
|
@ -1037,7 +1053,7 @@ namespace Vanara.PInvoke
|
||||||
/// </para>
|
/// </para>
|
||||||
/// <para>This information is not required for virtual folders.</para>
|
/// <para>This information is not required for virtual folders.</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoTaskMemStringMarshaler))] public string pszIcon;
|
public StrPtrUni pszIcon;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Optional. A pointer to a Security Descriptor Definition Language format string. This is a null-terminated Unicode string that
|
/// Optional. A pointer to a Security Descriptor Definition Language format string. This is a null-terminated Unicode string that
|
||||||
|
@ -1045,7 +1061,7 @@ namespace Vanara.PInvoke
|
||||||
/// folder inherits the security descriptor of its parent. This is particularly useful for common folders that are accessed by
|
/// folder inherits the security descriptor of its parent. This is particularly useful for common folders that are accessed by
|
||||||
/// all users.
|
/// all users.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoTaskMemStringMarshaler))] public string pszSecurity;
|
public StrPtrUni pszSecurity;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Optional. Default file system attributes given to the folder when it is created. For example, the file could be hidden and
|
/// Optional. Default file system attributes given to the folder when it is created. For example, the file could be hidden and
|
||||||
|
|
|
@ -134,27 +134,27 @@ namespace Vanara.PInvoke
|
||||||
public struct STRRET
|
public struct STRRET
|
||||||
{
|
{
|
||||||
/// <summary>A value that specifies the desired format of the string.</summary>
|
/// <summary>A value that specifies the desired format of the string.</summary>
|
||||||
[FieldOffset(0)] public STRRET_TYPE uType;
|
[FieldOffset(0)]
|
||||||
|
public STRRET_TYPE uType;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A pointer to the string. This memory must be allocated with CoTaskMemAlloc. It is the calling application's responsibility to
|
/// A pointer to the string. This memory must be allocated with CoTaskMemAlloc. It is the calling application's responsibility to
|
||||||
/// free this memory with CoTaskMemFree when it is no longer needed.
|
/// free this memory with CoTaskMemFree when it is no longer needed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[FieldOffset(4), MarshalAs(UnmanagedType.BStr)]
|
[FieldOffset(4)]
|
||||||
public StrPtrUni pOleStr; // must be freed by caller of GetDisplayNameOf
|
public StrPtrUni pOleStr; // must be freed by caller of GetDisplayNameOf
|
||||||
|
|
||||||
/// <summary>The offset into the item identifier list.</summary>
|
/// <summary>The offset into the item identifier list.</summary>
|
||||||
[FieldOffset(4)] public uint uOffset; // Offset into SHITEMID
|
[FieldOffset(4)]
|
||||||
|
public uint uOffset; // Offset into SHITEMID
|
||||||
|
|
||||||
/// <summary>The buffer to receive the display name. CHAR[MAX_PATH]</summary>
|
/// <summary>The buffer to receive the display name. CHAR[MAX_PATH]</summary>
|
||||||
[FieldOffset(4), MarshalAs(UnmanagedType.LPStr, SizeConst = Kernel32.MAX_PATH)]
|
[FieldOffset(4)]
|
||||||
public string cStr; // Buffer to fill in (ANSI)
|
public StrPtrAnsi cStr;
|
||||||
|
|
||||||
/// <summary>Returns a <see cref="System.String"/> that represents this instance.</summary>
|
/// <summary>Returns a <see cref="System.String"/> that represents this instance.</summary>
|
||||||
/// <returns>A <see cref="System.String"/> that represents this instance.</returns>
|
/// <returns>A <see cref="System.String"/> that represents this instance.</returns>
|
||||||
public override string ToString() => uType == STRRET_TYPE.STRRET_CSTR
|
public override string ToString() => (uType == STRRET_TYPE.STRRET_CSTR ? cStr : (uType == STRRET_TYPE.STRRET_WSTR ? pOleStr : (string)null)) ?? string.Empty;
|
||||||
? cStr
|
|
||||||
: (uType == STRRET_TYPE.STRRET_WSTR ? pOleStr.ToString() : string.Empty);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class STRRETMarshaler : ICustomMarshaler
|
internal class STRRETMarshaler : ICustomMarshaler
|
||||||
|
|
|
@ -53,7 +53,7 @@ namespace Vanara.PInvoke
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
// https://docs.microsoft.com/en-us/windows/desktop/api/thumbcache/nn-thumbcache-ithumbnailprovider
|
// https://docs.microsoft.com/en-us/windows/desktop/api/thumbcache/nn-thumbcache-ithumbnailprovider
|
||||||
[PInvokeData("thumbcache.h", MSDNShortId = "55c4739a-4835-4f53-a435-804ddf06ffcf")]
|
[PInvokeData("thumbcache.h", MSDNShortId = "55c4739a-4835-4f53-a435-804ddf06ffcf")]
|
||||||
[ComImport, Guid("e357fccd-a995-4576-b01f-234630154e96"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
[ComImport, Guid("e357fccd-a995-4576-b01f-234630154e96"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), CoClass(typeof(PhotoThumbnailProvider))]
|
||||||
public interface IThumbnailProvider
|
public interface IThumbnailProvider
|
||||||
{
|
{
|
||||||
/// <summary>Gets a thumbnail image and alpha type.</summary>
|
/// <summary>Gets a thumbnail image and alpha type.</summary>
|
||||||
|
@ -79,26 +79,6 @@ namespace Vanara.PInvoke
|
||||||
/// <summary>An implementation of IThumbnailProvider for photo thumbnails is supplied in Microsoft Windows as CLSID_PhotoThumbnailProvider.</summary>
|
/// <summary>An implementation of IThumbnailProvider for photo thumbnails is supplied in Microsoft Windows as CLSID_PhotoThumbnailProvider.</summary>
|
||||||
[ComImport, Guid("C7657C4A-9F68-40fa-A4DF-96BC08EB3551"), ClassInterface(ClassInterfaceType.None)]
|
[ComImport, Guid("C7657C4A-9F68-40fa-A4DF-96BC08EB3551"), ClassInterface(ClassInterfaceType.None)]
|
||||||
[PInvokeData("thumbcache.h")]
|
[PInvokeData("thumbcache.h")]
|
||||||
public class PhotoThumbnailProvider : IThumbnailProvider
|
public class PhotoThumbnailProvider { }
|
||||||
{
|
|
||||||
/// <summary>Gets a thumbnail image and alpha type.</summary>
|
|
||||||
/// <param name="cx">
|
|
||||||
/// The maximum thumbnail size, in pixels. The Shell draws the returned bitmap at this size or smaller. The returned bitmap
|
|
||||||
/// should fit into a square of width and height cx, though it does not need to be a square image. The Shell scales the bitmap to
|
|
||||||
/// render at lower sizes. For example, if the image has a 6:4 aspect ratio, then the returned bitmap should also have a 6:4
|
|
||||||
/// aspect ratio.
|
|
||||||
/// </param>
|
|
||||||
/// <param name="phbmp">
|
|
||||||
/// When this method returns, contains a pointer to the thumbnail image handle. The image must be a DIB section and 32 bits per
|
|
||||||
/// pixel. The Shell scales down the bitmap if its width or height is larger than the size specified by cx. The Shell always
|
|
||||||
/// respects the aspect ratio and never scales a bitmap larger than its original size.
|
|
||||||
/// </param>
|
|
||||||
/// <param name="pdwAlpha">
|
|
||||||
/// When this method returns, contains a pointer to one of the following values from the WTS_ALPHATYPE enumeration.
|
|
||||||
/// </param>
|
|
||||||
/// <returns>If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
|
|
||||||
[PreserveSig]
|
|
||||||
public extern HRESULT GetThumbnail(uint cx, out HBITMAP phbmp, out WTS_ALPHATYPE pdwAlpha);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue