From 64f17443256b2d84620d8c037e6c9f6104ea5a9a Mon Sep 17 00:00:00 2001 From: dahall Date: Tue, 19 Oct 2021 18:27:45 -0600 Subject: [PATCH] Fixed passing of PROPVARIANT params in IPortableXX interface methods --- PInvoke/PortableDeviceApi/PortableDeviceTypes.cs | 108 +++++++++++------------ 1 file changed, 53 insertions(+), 55 deletions(-) diff --git a/PInvoke/PortableDeviceApi/PortableDeviceTypes.cs b/PInvoke/PortableDeviceApi/PortableDeviceTypes.cs index 27aae22a..d3b6367c 100644 --- a/PInvoke/PortableDeviceApi/PortableDeviceTypes.cs +++ b/PInvoke/PortableDeviceApi/PortableDeviceTypes.cs @@ -9,6 +9,30 @@ namespace Vanara.PInvoke { public static partial class PortableDeviceApi { + /// + /// The WPD_STREAM_UNITS enumeration specifies the unit types to be used for IPortableDeviceUnitsStream operations. + /// + // https://docs.microsoft.com/en-us/windows/win32/wpd_sdk/wpd-stream-units typedef enum _WPD_STREAM_UNITS { WPD_STREAM_UNITS_BYTES = + // 0, WPD_STREAM_UNITS_FRAMES = 1, WPD_STREAM_UNITS_ROWS = 2, WPD_STREAM_UNITS_MILLISECONDS = 3, WPD_STREAM_UNITS_MICROSECONDS = 4 } WPD_STREAM_UNITS; + [PInvokeData("portabldevicetypes.h")] + public enum WPD_STREAM_UNITS + { + /// The stream units are specified in bytes. + WPD_STREAM_UNITS_BYTES = 0, + + /// The stream units are specified in frames. + WPD_STREAM_UNITS_FRAMES = 1, + + /// The stream units are specified in rows. + WPD_STREAM_UNITS_ROWS = 2, + + /// The stream units are specified in milliseconds. + WPD_STREAM_UNITS_MILLISECONDS = 4, + + /// The stream units are specified in microseconds. + WPD_STREAM_UNITS_MICROSECONDS = 8, + } + /// /// The IPortableDeviceKeyCollection interface holds a collection of PROPERTYKEY values. This interface can be /// retrieved from a method or, if a new object is required, call CoCreate with CLSID_PortableDeviceKeyCollection. @@ -19,14 +43,14 @@ namespace Vanara.PInvoke public interface IPortableDeviceKeyCollection { /// The GetCount method retrieves the number of keys in this collection. - /// Pointer to a DWORD that contains the number of keys in the collection. + /// A DWORD that contains the number of keys in the collection. // https://docs.microsoft.com/en-us/windows/win32/wpd_sdk/iportabledevicekeycollection-getcount HRESULT GetCount( [in] DWORD // *pcElems ); uint GetCount(); /// The GetAt method retrieves a PROPERTYKEY from the collection by index. /// DWORD that contains the index of the key to be retrieved. - /// Pointer to a PROPERTYKEY object. + /// A PROPERTYKEY object. // https://docs.microsoft.com/en-us/windows/win32/wpd_sdk/iportabledevicekeycollection-getat HRESULT GetAt( [in] const DWORD // dwIndex, [out] PROPERTYKEY *pKey ); PROPERTYKEY GetAt([In] uint dwIndex); @@ -75,17 +99,15 @@ namespace Vanara.PInvoke /// The GetAt method retrieves an item from the collection by a zero-based index. /// DWORD that contains the zero-based index of the item to retrieve. - /// - /// Pointer to a PROPVARIANT structure. The caller is responsible for freeing this memory by calling PropVariantClear. - /// + /// A PROPVARIANT structure. The caller is responsible for freeing this memory by calling PropVariantClear. // https://docs.microsoft.com/en-us/windows/win32/wpd_sdk/iportabledevicepropvariantcollection-getat HRESULT GetAt( [in] const // DWORD dwIndex, [out] PROPVARIANT *pValue ); - void GetAt([In] uint dwIndex, [In, Out] PROPVARIANT pValue); + void GetAt([In] uint dwIndex, [Out] PROPVARIANT pValue); /// The Add method adds an item to the collection. /// - /// Pointer to a new PROPVARIANT object to add to the collection. This method copies the PROPVARIANT to the - /// collection, so you should release your local copy of the variable by calling PropVariantClear after calling this method. + /// A new PROPVARIANT object to add to the collection. This method copies the PROPVARIANT to the collection, so + /// you should release your local copy of the variable by calling PropVariantClear after calling this method. /// /// /// @@ -166,7 +188,7 @@ namespace Vanara.PInvoke public interface IPortableDeviceValues { /// The GetCount method retrieves the number of items in the collection. - /// Pointer to a DWORD that contains the number of items in the collection. + /// A DWORD that contains the number of items in the collection. // https://docs.microsoft.com/en-us/windows/win32/wpd_sdk/iportabledevicevalues-getcount HRESULT GetCount( [in] DWORD *pcelt ); uint GetCount(); @@ -184,7 +206,7 @@ namespace Vanara.PInvoke /// // https://docs.microsoft.com/en-us/windows/win32/wpd_sdk/iportabledevicevalues-getat HRESULT GetAt( [in] const DWORD index, // [in, out] PROPERTYKEY *pKey, [in, out] PROPVARIANT *pValue ); - void GetAt([In] uint index, out PROPERTYKEY pKey, PROPVARIANT pValue); + void GetAt(uint index, out PROPERTYKEY pKey, [Out] PROPVARIANT pValue); /// The SetValue method adds a new PROPVARIANT value or overwrites an existing one. /// A REFPROPERTYKEY that specifies the item to create or overwrite. @@ -484,8 +506,8 @@ namespace Vanara.PInvoke /// /// A REFPROPERTYKEY that specifies the item to create or overwrite. /// - /// Pointer to an IPortableDeviceValues interface that specifies the new value. The SDK copies a reference to the - /// submitted interface and calls AddRef on it. + /// An IPortableDeviceValues interface that specifies the new value. The SDK copies a reference to the submitted + /// interface and calls AddRef on it. /// /// /// If an existing value has the same key that is specified by the key parameter, it overwrites the existing value without any @@ -514,8 +536,8 @@ namespace Vanara.PInvoke /// /// A REFPROPERTYKEY that specifies the item to create or overwrite. /// - /// Pointer to an IPortableDevicePropVariantCollection interface that specifies the new value. The SDK copies a reference - /// to the submitted interface and calls AddRef on it. + /// An IPortableDevicePropVariantCollection interface that specifies the new value. The SDK copies a reference to the + /// submitted interface and calls AddRef on it. /// /// /// If an existing value has the same key that is specified by the key parameter, it overwrites the existing value without any @@ -543,8 +565,8 @@ namespace Vanara.PInvoke /// Adds a new SetIPortableDeviceKeyCollectionValue value (type VT_UNKNOWN) or overwrites an existing one. /// [in] A REFPROPERTYKEY that specifies the item to create or overwrite. /// - /// [in] Pointer to an IPortableDeviceKeyCollection interface that specifies the new value. The SDK copies a reference to - /// the submitted interface and calls AddRef on it. + /// [in] An IPortableDeviceKeyCollection interface that specifies the new value. The SDK copies a reference to the + /// submitted interface and calls AddRef on it. /// /// /// If an existing value has the same key that is specified by the key parameter, it overwrites the existing value without any @@ -568,8 +590,8 @@ namespace Vanara.PInvoke /// Adds a new IPortableDeviceValuesCollection value (type VT_UNKNOWN) or overwrites an existing one. /// [in] A REFPROPERTYKEY that specifies the item to create or overwrite. /// - /// [in] Pointer to an IPortableDeviceValuesCollection interface that specifies the new value. The SDK copies a reference - /// to the submitted interface and calls AddRef on it. + /// [in] An IPortableDeviceValuesCollection interface that specifies the new value. The SDK copies a reference to the + /// submitted interface and calls AddRef on it. /// /// /// If an existing value has the same key that is specified by the key parameter, it overwrites the existing value without any @@ -597,7 +619,7 @@ namespace Vanara.PInvoke void RemoveValue(in PROPERTYKEY key); /// The CopyValuesFromPropertyStore method copies the contents of an IPropertyStore into the collection. - /// Pointer to an IPropertyStore to copy into the collection. + /// An IPropertyStore to copy into the collection. /// /// This method automatically converts all VT_BSTR values to VT_LPWSTR values. /// @@ -613,7 +635,7 @@ namespace Vanara.PInvoke /// /// The CopyValuesToPropertyStore method copies all the values from a collection into an IPropertyStore interface. /// - /// Pointer to a store object. + /// A store object. /// /// /// This method does not convert values of VT_LPWSTR into VT_BSTR. Many external applications or components that communicate @@ -662,8 +684,8 @@ namespace Vanara.PInvoke /// The Add method adds an item to the collection. /// - /// Pointer to an IPortableDeviceValues interface to add to the collection. The interface is not actually copied, but - /// AddRef is called on it. + /// An IPortableDeviceValues interface to add to the collection. The interface is not actually copied, but AddRef + /// is called on it. /// // https://docs.microsoft.com/en-us/windows/win32/wpd_sdk/iportabledevicevaluescollection-add HRESULT Add( [in] // IPortableDeviceValues *pValues ); @@ -716,10 +738,10 @@ namespace Vanara.PInvoke /// caller-allocated byte array. /// /// DWORD that specifies the size of pBuffer, in bytes. - /// Pointer to an IPortableDeviceValues interface to serialize. - /// Pointer to a caller-allocated buffer. To learn the size of the required buffer, call GetSerializedSize. + /// An IPortableDeviceValues interface to serialize. + /// A caller-allocated buffer. To learn the size of the required buffer, call GetSerializedSize. /// - /// Pointer to a DWORD that indicates the number of bytes that was actually written to the caller-allocated buffer. + /// A DWORD that indicates the number of bytes that was actually written to the caller-allocated buffer. /// /// /// This method copies an IPortableDeviceValues interface into an existing buffer. If you want to allocate a new buffer, @@ -734,12 +756,12 @@ namespace Vanara.PInvoke /// The GetBufferFromIPortableDeviceValues method serializes a submitted IPortableDeviceValues interface to an /// allocated byte array. The byte array returned is allocated for the caller and should be freed by the caller using CoTaskMemFree. /// - /// Pointer to an IPortableDeviceValues interface to serialize. + /// An IPortableDeviceValues interface to serialize. /// - /// Pointer to a BYTE* that contains the serialized data. Windows Portable Devices allocates this memory; the caller must - /// free it by calling CoTaskMemFree. + /// A BYTE* that contains the serialized data. Windows Portable Devices allocates this memory; the caller must free it by + /// calling CoTaskMemFree. /// - /// Pointer to a DWORD that specifies the size of allocated buffer, in bytes. + /// A DWORD that specifies the size of allocated buffer, in bytes. // https://docs.microsoft.com/en-us/windows/win32/wpd_sdk/iwpdserializer-getbufferfromiportabledevicevalues HRESULT // GetBufferFromIPortableDeviceValues( [in] IPortableDeviceValues *pSource, [out] BYTE **ppBuffer, [out] DWORD *pdwBufferSize ); void GetBufferFromIPortableDeviceValues(IPortableDeviceValues pSource, out SafeCoTaskMemHandle ppBuffer, out uint pdwBufferSize); @@ -748,8 +770,8 @@ namespace Vanara.PInvoke /// The GetSerializedSize method calculates the buffer size that is required to hold a serialized /// IPortableDeviceValues interface. /// - /// Pointer to an IPortableDeviceValues interface whose size you want to request. - /// Pointer to a DWORD that indicates the buffer size that is required to serialize pSource, in bytes. + /// An IPortableDeviceValues interface whose size you want to request. + /// A DWORD that indicates the buffer size that is required to serialize pSource, in bytes. // https://docs.microsoft.com/en-us/windows/win32/wpd_sdk/iwpdserializer-getserializedsize HRESULT GetSerializedSize( [in] // IPortableDeviceValues *pSource, [out] DWORD *pdwSize ); uint GetSerializedSize(IPortableDeviceValues pSource); @@ -785,30 +807,6 @@ namespace Vanara.PInvoke public static PROPERTYKEY GetCommandPKey(this IPortableDeviceValues iValues) => new PROPERTYKEY(iValues.GetGuidValue(WPD_PROPERTY_COMMON_COMMAND_CATEGORY), iValues.GetUnsignedIntegerValue(WPD_PROPERTY_COMMON_COMMAND_ID)); - /// - /// The WPD_STREAM_UNITS enumeration specifies the unit types to be used for IPortableDeviceUnitsStream operations. - /// - // https://docs.microsoft.com/en-us/windows/win32/wpd_sdk/wpd-stream-units typedef enum _WPD_STREAM_UNITS { WPD_STREAM_UNITS_BYTES = - // 0, WPD_STREAM_UNITS_FRAMES = 1, WPD_STREAM_UNITS_ROWS = 2, WPD_STREAM_UNITS_MILLISECONDS = 3, WPD_STREAM_UNITS_MICROSECONDS = 4 } WPD_STREAM_UNITS; - [PInvokeData("portabldevicetypes.h")] - public enum WPD_STREAM_UNITS - { - /// The stream units are specified in bytes. - WPD_STREAM_UNITS_BYTES = 0, - - /// The stream units are specified in frames. - WPD_STREAM_UNITS_FRAMES = 1, - - /// The stream units are specified in rows. - WPD_STREAM_UNITS_ROWS = 2, - - /// The stream units are specified in milliseconds. - WPD_STREAM_UNITS_MILLISECONDS = 4, - - /// The stream units are specified in microseconds. - WPD_STREAM_UNITS_MICROSECONDS = 8, - } - /// PortableDeviceKeyCollection Class [PInvokeData("portabldevicetypes.h")] [ComImport, Guid("de2d022d-2480-43be-97f0-d1fa2cf98f4f"), ClassInterface(ClassInterfaceType.None)]