using System;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using Vanara.InteropServices;
using static Vanara.PInvoke.Ole32;
using static Vanara.PInvoke.OleAut32;
using FILETIME = System.Runtime.InteropServices.ComTypes.FILETIME;
namespace Vanara.PInvoke
{
/// Platform invokable enumerated types, constants and functions from propsys.h
public static partial class PropSys
{
/// Values used by the function.
[PInvokeData("Propvarutil.h")]
[Flags]
public enum PROPVAR_CHANGE_FLAGS
{
/// The PVCHF default
PVCHF_DEFAULT = 0x00000000,
/// Maps to VARIANT_NOVALUEPROP for VariantChangeType
PVCHF_NOVALUEPROP = 0x00000001,
/// Maps to VARIANT_ALPHABOOL for VariantChangeType
PVCHF_ALPHABOOL = 0x00000002,
/// Maps to VARIANT_NOUSEROVERRIDE for VariantChangeType
PVCHF_NOUSEROVERRIDE = 0x00000004,
/// Maps to VARIANT_LOCALBOOL for VariantChangeType
PVCHF_LOCALBOOL = 0x00000008,
/// Don't convert a string that looks like hexadecimal (0xABCD) to the numerical equivalent.
PVCHF_NOHEXSTRING = 0x00000010
}
/// Values used by the function.
[Flags]
[PInvokeData("Propvarutil.h")]
public enum PROPVAR_COMPARE_FLAGS
{
/// When comparing strings, use StrCmpLogical
PVCF_DEFAULT = 0x00000000,
/// Empty/null values are greater-than non-empty values
PVCF_TREATEMPTYASGREATERTHAN = 0x00000001,
/// When comparing strings, use StrCmp
PVCF_USESTRCMP = 0x00000002,
/// When comparing strings, use StrCmpC
PVCF_USESTRCMPC = 0x00000004,
/// When comparing strings, use StrCmpI
PVCF_USESTRCMPI = 0x00000008,
/// When comparing strings, use StrCmpIC
PVCF_USESTRCMPIC = 0x00000010,
///
/// When comparing strings, use CompareStringEx with LOCALE_NAME_USER_DEFAULT and SORT_DIGITSASNUMBERS. This corresponds to the
/// linguistically correct order for UI lists.
///
PVCF_DIGITSASNUMBERS_CASESENSITIVE = 0x00000020,
}
/// Values used by the function.
[PInvokeData("Propvarutil.h")]
public enum PROPVAR_COMPARE_UNIT
{
/// The default unit.
PVCU_DEFAULT = 0,
/// The second comparison unit.
PVCU_SECOND = 1,
/// The minute comparison unit.
PVCU_MINUTE = 2,
/// The hour comparison unit.
PVCU_HOUR = 3,
/// The day comparison unit.
PVCU_DAY = 4,
/// The month comparison unit.
PVCU_MONTH = 5,
/// The year comparison unit.
PVCU_YEAR = 6
}
/// Values used by the function.
[PInvokeData("Propvarutil.h")]
public enum PSTIME_FLAGS
{
/// Indicates the output will use coordinated universal time.
PSTF_UTC = 0x00000000,
/// Indicates the output will use local time.
PSTF_LOCAL = 0x00000001
}
///
/// Frees the memory and references used by an array of PROPVARIANT structures stored in an array.
///
///
/// Type: PROPVARIANT*
/// Array of PROPVARIANT structures to free.
///
///
/// Type: UINT
/// The number of elements in the array specified by rgPropVar.
///
///
/// No return value.
///
///
///
/// This function releases the memory and references held by each structure in the array before setting the structures to zero.
///
/// This function performs the same action as FreePropVariantArray, but FreePropVariantArray returns an HRESULT.
/// Examples
/// The following example, to be included as part of a larger program, demonstrates how to use ClearPropVariantArray
///
// https://docs.microsoft.com/en-us/windows/desktop/api/propvarutil/nf-propvarutil-clearpropvariantarray PSSTDAPI_(void)
// ClearPropVariantArray( PROPVARIANT *rgPropVar, UINT cVars );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "e8d7f951-8a9e-441b-9fa7-bf21cf08c8ac")]
public static extern HRESULT ClearPropVariantArray([In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] PROPVARIANT[] rgPropVar, uint cVars);
/// Frees the memory and references used by an array of VARIANT structures stored in an array.
///
/// Type: VARIANT*
/// Array of VARIANT structures to free.
///
///
/// Type: UINT
/// The number of elements in the array specified by pvars.
///
/// No return value.
///
///
/// This function releases the memory and references held by each structure in the array before it sets the structures to zero.
///
/// Examples
/// The following example, to be included as part of a larger program, demonstrates how to use ClearVariantArray
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-clearvariantarray PSSTDAPI_(void) ClearVariantArray(
// VARIANT *pvars, UINT cvars );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "8126392e-d86c-420c-9f0d-ca7cb97030b0")]
public static extern void ClearVariantArray([In, Out] VARIANT[] pvars, uint cvars);
/// Initializes a structure from a specified Boolean vector.
///
/// Pointer to the Boolean vector used to initialize the structure. If this parameter is NULL, the elements pointed to by the
/// cabool.pElems structure member are initialized with VARIANT_FALSE.
///
/// The number of vector elements.
/// When this function returns, contains the initialized structure.
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
[DllImport(Lib.PropSys, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb762288")]
public static extern HRESULT InitPropVariantFromBooleanVector([In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1, ArraySubType = UnmanagedType.Bool)] bool[] prgf, uint cElems, [In, Out] PROPVARIANT ppropvar);
/// Initializes a structure using the contents of a buffer.
/// Pointer to the buffer.
/// The length of the buffer, in bytes.
/// When this function returns, contains the initialized structure.
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
[DllImport(Lib.PropSys, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb762289")]
public static extern HRESULT InitPropVariantFromBuffer([In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1, ArraySubType = UnmanagedType.U1)] byte[] pv, uint cb, [In, Out] PROPVARIANT ppropvar);
/// Initializes a structure based on a class identifier (CLSID).
/// Reference to the CLSID.
/// When this function returns, contains the initialized structure.
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
[DllImport(Lib.PropSys, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb762290")]
public static extern HRESULT InitPropVariantFromCLSID(in Guid clsid, [In, Out] PROPVARIANT ppropvar);
/// Initializes a structure based on a specified vector of double values.
///
/// Pointer to a double vector. If this value is NULL, the elements pointed to by the cadbl.pElems structure member are initialized
/// with 0.0.
///
/// The number of vector elements.
/// When this function returns, contains the initialized structure.
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
[DllImport(Lib.PropSys, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb762292")]
public static extern HRESULT InitPropVariantFromDoubleVector([In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1, ArraySubType = UnmanagedType.R8)] double[] prgn, uint cElems, [In, Out] PROPVARIANT ppropvar);
/// Initializes a structure based on information stored in a structure.
/// Pointer to the date and time as a structure.
/// When this function returns, contains the initialized structure.
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
[DllImport(Lib.PropSys, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb762293")]
public static extern HRESULT InitPropVariantFromFileTime(in FILETIME pftIn, [In, Out] PROPVARIANT ppropvar);
/// Initializes a structure from a specified vector of values.
///
/// Pointer to the date and time as a vector. If this value is NULL, the elements pointed to by the
/// cafiletime.pElems structure member is initialized with (FILETIME)0.
///
/// The number of vector elements.
/// When this function returns, contains the initialized structure.
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
[DllImport(Lib.PropSys, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb762294")]
public static extern HRESULT InitPropVariantFromFileTimeVector([In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] FILETIME[] prgft, uint cElems, [In, Out] PROPVARIANT ppropvar);
///
/// Initializes a PROPVARIANT structure based on a GUID. The structure is initialized as VT_LPWSTR.
///
///
/// Type: REFGUID
/// Reference to the source GUID.
///
///
/// Type: PROPVARIANT*
/// When this function returns, contains the initialized PROPVARIANT structure.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
///
/// Creates a VT_LPWSTR PROPVARIANT, which formats the GUID in a form similar to .
/// Examples
/// The following example, to be included as part of a larger program, demonstrates how to use InitPropVariantFromGUIDAsString.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/propvarutil/nf-propvarutil-initpropvariantfromguidasstring PSSTDAPI
// InitPropVariantFromGUIDAsString( REFGUID guid, PROPVARIANT *ppropvar );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "bcc343f7-741f-4cdd-bd2f-ae4786faab0e")]
public static extern HRESULT InitPropVariantFromGUIDAsString(in Guid guid, [In, Out] PROPVARIANT ppropvar);
/// Initializes a structure based on a specified vector of 16-bit integer values.
/// Pointer to a source vector of SHORT values. If this parameter is NULL, the vector is initialized with zeros.
/// The number of elements in the vector.
/// When this function returns, contains the initialized structure.
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
[DllImport(Lib.PropSys, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb762298")]
public static extern HRESULT InitPropVariantFromInt16Vector([In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1, ArraySubType = UnmanagedType.I2)] short[] prgn, uint cElems, [In, Out] PROPVARIANT ppropvar);
/// Initializes a structure based on a specified vector of 32-bit integer values.
/// Pointer to a source vector of LONG values. If this parameter is NULL, the vector is initialized with zeros.
/// The number of elements in the vector.
/// When this function returns, contains the initialized structure.
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
[DllImport(Lib.PropSys, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb762300")]
public static extern HRESULT InitPropVariantFromInt32Vector([In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1, ArraySubType = UnmanagedType.I4)] int[] prgn, uint cElems, [In, Out] PROPVARIANT ppropvar);
/// Initializes a structure based on a specified vector of 64-bit integer values.
///
/// Pointer to a source vector of LONGLONG values. If this parameter is NULL, the vector is initialized with zeros.
///
/// The number of elements in the vector.
/// When this function returns, contains the initialized structure.
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
[DllImport(Lib.PropSys, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb762302")]
public static extern HRESULT InitPropVariantFromInt64Vector([In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1, ArraySubType = UnmanagedType.I8)] long[] prgn, uint cElems, [In, Out] PROPVARIANT ppropvar);
/// Initializes a structure based on a specified vector element.
///
/// This function extracts a single value from the source structure and uses that value to initialize the
/// output PROPVARIANT structure. The calling application must use to free the
/// PROPVARIANT referred to by ppropvar when it is no longer needed.
///
/// If the source PROPVARIANT is a vector or array, iElem must be less than the number of elements in the vector or array.
///
/// If the source PROPVARIANT has a single value, iElem must be 0.
/// If the source PROPVARIANT is empty, this function always returns an error code.
/// You can use to obtain the number of elements in the vector or array.
///
/// The source structure.
/// The index of the source structure element.
/// When this function returns, contains the initialized structure.
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
[DllImport(Lib.PropSys, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb762303")]
public static extern HRESULT InitPropVariantFromPropVariantVectorElem([In] PROPVARIANT propvarIn, uint iElem, [In, Out] PROPVARIANT ppropvar);
///
/// Initializes a PROPVARIANT structure based on a string resource embedded in an executable file.
///
///
/// Type: HINSTANCE
/// Handle to an instance of the module whose executable file contains the string resource.
///
///
/// Type: UINT
/// Integer identifier of the string to be loaded.
///
///
/// Type: PROPVARIANT*
/// When this function returns, contains the initialized PROPVARIANT structure.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
///
///
/// This function creates a VT_LPWSTR propvariant. If the specified resource does not exist, it initializes the PROPVARIANT with an
/// empty string. Resource strings longer than 1024 characters are truncated and null-terminated.
///
/// Examples
/// The following example, to be included as part of a larger program, demonstrates how to use InitPropVariantFromResource.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/propvarutil/nf-propvarutil-initpropvariantfromresource PSSTDAPI
// InitPropVariantFromResource( HINSTANCE hinst, UINT id, PROPVARIANT *ppropvar );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "c958f823-f820-4b0b-86ed-84ad18befbd1")]
public static extern HRESULT InitPropVariantFromResource(HINSTANCE hinst, uint id, [In, Out] PROPVARIANT ppropvar);
/// Initializes the property variant from string.
/// Pointer to a buffer that contains the source Unicode string.
/// When this function returns, contains the initialized PROPVARIANT structure.
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
[PInvokeData("propvarutil.h", MSDNShortId = "cee95d17-532d-8e34-a392-a04778f9bc00")]
public static HRESULT InitPropVariantFromString(string psz, [In, Out] PROPVARIANT ppropvar)
{
PropVariantClear(ppropvar);
if (psz is null) return HRESULT.E_INVALIDARG;
ppropvar._ptr = Marshal.StringToCoTaskMemUni(psz);
ppropvar.vt = VARTYPE.VT_LPWSTR;
return HRESULT.S_OK;
}
///
///
/// Initializes a PROPVARIANT structure from a specified string. The string is parsed as a semi-colon delimited list (for example: "A;B;C").
///
///
///
/// Type: PCWSTR
/// Pointer to a buffer that contains the source Unicode string.
///
///
/// Type: PROPVARIANT*
/// When this function returns, contains the initialized PROPVARIANT structure.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
///
///
/// Creates a VT_VECTOR | VT_LPWSTR propvariant. It parses the source string as a semicolon list of values. The string "a; b; c"
/// creates a vector with three values. Leading and trailing whitespace are removed, and empty values are omitted.
///
/// If psz is NULL or contains no values, the PROPVARIANT structure is initialized as VT_EMPTY.
/// Examples
/// The following example, to be included as part of a larger program, demonstrates how to use InitPropVariantFromStringAsVector.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/propvarutil/nf-propvarutil-initpropvariantfromstringasvector PSSTDAPI
// InitPropVariantFromStringAsVector( PCWSTR psz, PROPVARIANT *ppropvar );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "fc48f2e0-ce4a-4f48-a624-202def4bcff0")]
public static extern HRESULT InitPropVariantFromStringAsVector([MarshalAs(UnmanagedType.LPWStr)] string psz, [In, Out] PROPVARIANT ppropvar);
/// Initializes a structure based on a specified string vector.
/// Pointer to a buffer that contains the source string vector.
/// The number of vector elements in .
/// When this function returns, contains the initialized structure.
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
[DllImport(Lib.PropSys, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb762307")]
public static extern HRESULT InitPropVariantFromStringVector([In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1, ArraySubType = UnmanagedType.LPWStr)] string[] prgsz, uint cElems, [In, Out] PROPVARIANT ppropvar);
///
/// Initializes a PROPVARIANT structure based on a string stored in a STRRET structure.
///
///
/// Type: STRRET*
/// Pointer to a STRRET structure that contains the string.
///
///
/// Type: PCUITEMID_CHILD
/// PIDL of the item whose details are being retrieved.
///
///
/// Type: PROPVARIANT*
/// When this function returns, contains the initialized PROPVARIANT structure.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
///
/// Creates a VT_LPWSTR propvariant.
/// Note This function frees the memory used for the STRRET contents.
/// Examples
/// The following example, to be included as part of a larger program, demonstrates how to use InitPropVariantFromStrRet.
///
// https://docs.microsoft.com/en-us/windows/desktop/api/propvarutil/nf-propvarutil-initpropvariantfromstrret PSSTDAPI
// InitPropVariantFromStrRet( STRRET *pstrret, PCUITEMID_CHILD pidl, PROPVARIANT *ppropvar );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "5c02e2ee-14c2-4966-83e7-16dfbf81b879")]
public static extern HRESULT InitPropVariantFromStrRet(IntPtr pstrret, IntPtr pidl, [In, Out] PROPVARIANT ppropvar);
/// Initializes a structure based on a specified string vector.
/// The PRGN.
/// The number of vector elements in .
/// When this function returns, contains the initialized structure.
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
[DllImport(Lib.PropSys, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb762310")]
public static extern HRESULT InitPropVariantFromUInt16Vector([In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1, ArraySubType = UnmanagedType.U2)] ushort[] prgn, uint cElems, [In, Out] PROPVARIANT ppropvar);
/// Initializes a structure based on a vector of 32-bit unsigned integer values.
///
/// Pointer to a source vector of ULONG values. If this parameter is NULL, the is initialized with zeros.
///
/// The number of vector elements in .
/// When this function returns, contains the initialized structure.
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
[DllImport(Lib.PropSys, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb762312")]
public static extern HRESULT InitPropVariantFromUInt32Vector([In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1, ArraySubType = UnmanagedType.U4)] uint[] prgn, uint cElems, [In, Out] PROPVARIANT ppropvar);
/// Initializes a structure based on a vector of 64-bit unsigned integer values.
///
/// Pointer to a source vector of ULONGLONG values. If this parameter is NULL, the is initialized with zeros.
///
/// The number of vector elements in .
/// When this function returns, contains the initialized structure.
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
[DllImport(Lib.PropSys, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb762314")]
public static extern HRESULT InitPropVariantFromUInt64Vector([In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1, ArraySubType = UnmanagedType.U8)] ulong[] prgn, uint cElems, [In, Out] PROPVARIANT ppropvar);
/// Initializes a vector element in a structure with a value stored in another PROPVARIANT.
/// Reference to the source structure that contains a single value.
/// When this function returns, contains the initialized structure.
///
/// Returns S_OK if successful, or a standard COM error value otherwise. If the requested coercion is not possible, an error is returned.
///
[DllImport(Lib.PropSys, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb762315")]
public static extern HRESULT InitPropVariantVectorFromPropVariant([In] PROPVARIANT propvarSingle, [Out] PROPVARIANT ppropvarVector);
/// Initializes a VARIANT structure from an array of Boolean values.
///
/// Type: const BOOL*
/// Pointer to source array of Boolean values.
///
///
/// Type: ULONG
/// The number of elements in the array.
///
///
/// Type: VARIANT*
/// When this function returns, contains the initialized VARIANT structure.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
///
/// Creates a VT_ARRAY | VT_BOOL variant.
/// Examples
/// The following example, to be included as part of a larger program, demonstrates how to use InitVariantFromBooleanArray.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-initvariantfrombooleanarray PSSTDAPI
// InitVariantFromBooleanArray( const BOOL *prgf, ULONG cElems, VARIANT *pvar );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "50780131-c0ed-443b-86e8-deb996a5c98e")]
public static extern HRESULT InitVariantFromBooleanArray([In, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.Bool, SizeParamIndex = 1)] bool[] prgf, uint cElems, out VARIANT pvar);
/// Initializes a VARIANT structure with the contents of a buffer.
///
/// Type: const VOID*
/// Pointer to the source buffer.
///
///
/// Type: UINT
/// The length of the buffer, in bytes.
///
///
/// Type: VARIANT*
/// When this function returns, contains the initialized VARIANT structure.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
///
/// Creates a VT_ARRAY | VT_UI1 variant..
/// Examples
/// The following example, to be included as part of a larger program, demonstrates how to use InitVariantFromBuffer.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-initvariantfrombuffer PSSTDAPI
// InitVariantFromBuffer( const void *pv, UINT cb, VARIANT *pvar );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "4dd28a13-2161-4258-a32f-57e5bd8ce091")]
public static extern HRESULT InitVariantFromBuffer([In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] byte[] pv, uint cb, out VARIANT pvar);
/// Initializes a VARIANT structure with an array of values of type DOUBLE.
///
/// Type: const DOUBLE*
/// Pointer to the source array of DOUBLE values.
///
///
/// Type: ULONG
/// The number of elements in the array pointed to by prgn.
///
///
/// Type: VARIANT*
/// When this function returns, contains the initialized VARIANT structure.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
///
/// Creates a VT_ARRAY | VT_R8 variant.
/// Examples
/// The following example, to be included as part of a larger program, demonstrates how to use InitVariantFromDoubleArray.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-initvariantfromdoublearray PSSTDAPI
// InitVariantFromDoubleArray( const DOUBLE *prgn, ULONG cElems, VARIANT *pvar );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "781b6999-4551-499d-ba37-0a7e05fc6eab")]
public static extern HRESULT InitVariantFromDoubleArray([In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] double[] prgn, uint cElems, out VARIANT pvar);
/// Initializes a VARIANT structure with the contents of a FILETIME structure.
///
/// Type: const FILETIME*
/// Pointer to date and time information stored in a FILETIME structure.
///
///
/// Type: VARIANT*
/// When this function returns, contains the initialized VARIANT structure.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
///
/// Creates a VT_DATE variant.
/// Examples
/// The following example, to be included as part of a larger program, demonstrates how to use InitVariantFromFileTime.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-initvariantfromfiletime PSSTDAPI
// InitVariantFromFileTime( const FILETIME *pft, VARIANT *pvar );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "cd61a268-ef73-4dd3-98d4-9811922d01f4")]
public static extern HRESULT InitVariantFromFileTime(in FILETIME pft, out VARIANT pvar);
/// Initializes a VARIANT structure with an array of FILETIME structures.
///
/// Type: const FILETIME*
/// Pointer to an array of FILETIME structures.
///
///
/// Type: ULONG
/// The number of elements in the array pointed to by prgft.
///
///
/// Type: VARIANT*
/// When this function returns, contains the initialized VARIANT structure.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
///
/// Creates a VT_ARRAY | VT_DATE variant.
/// Examples
/// The following example, to be included as part of a larger program, demonstrates how to use InitVariantFromFileTimeArray.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-initvariantfromfiletimearray PSSTDAPI
// InitVariantFromFileTimeArray( const FILETIME *prgft, ULONG cElems, VARIANT *pvar );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "d1b25aec-f302-4d39-93c1-0fcb2d7dbf45")]
public static extern HRESULT InitVariantFromFileTimeArray([In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] FILETIME[] prgft, uint cElems, out VARIANT pvar);
/// Initializes a VARIANT structure based on a GUID. The structure is initialized as a VT_BSTR type.
///
/// Type: REFGUID
/// Reference to the source GUID.
///
///
/// Type: VARIANT*
/// When this function returns, contains the initialized VARIANT structure.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
///
/// Creates a VT_BSTR variant, formatting the GUID in a form similar to .
/// Examples
/// The following example, to be included as part of a larger program, demonstrates how to use InitVariantFromGUIDAsString.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-initvariantfromguidasstring PSSTDAPI
// InitVariantFromGUIDAsString( REFGUID guid, VARIANT *pvar );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "2a78257a-a8ce-45e8-aea2-dfa9f380528a")]
public static extern HRESULT InitVariantFromGUIDAsString(in Guid guid, out VARIANT pvar);
/// Initializes a VARIANT structure with an array of 16-bit integer values.
///
/// Type: const SHORT*
/// Pointer to the source array of SHORT values.
///
///
/// Type: ULONG
/// The number of elements in the array pointed to by prgn.
///
///
/// Type: VARIANT*
/// When this function returns, contains the initialized VARIANT structure.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
///
/// Creates a VT_ARRAY | VT_I2 variant.
/// Examples
/// The following example, to be included as part of a larger program, demonstrates how to use InitVariantFromInt16Array.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-initvariantfromint16array PSSTDAPI
// InitVariantFromInt16Array( const SHORT *prgn, ULONG cElems, VARIANT *pvar );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "6aeca46e-96b5-42cb-b5db-2c1e3152d629")]
public static extern HRESULT InitVariantFromInt16Array([In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] short[] prgn, uint cElems, out VARIANT pvar);
/// Initializes a VARIANT structure with an array of 32-bit integer values.
///
/// Type: const LONG*
/// Pointer to the source array of LONG values.
///
///
/// Type: ULONG
/// The number of elements in the array pointed to by prgn.
///
///
/// Type: VARIANT*
/// When this function returns, contains the initialized VARIANT structure.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
///
/// Creates a VT_ARRAY | VT_I4 variant.
/// Examples
/// The following example, to be included as part of a larger program, demonstrates how to use InitVariantFromInt32Array.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-initvariantfromint32array PSSTDAPI
// InitVariantFromInt32Array( const LONG *prgn, ULONG cElems, VARIANT *pvar );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "0805d510-ee9c-4f10-978d-c34d572488f9")]
public static extern HRESULT InitVariantFromInt32Array([In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] int[] prgn, uint cElems, out VARIANT pvar);
/// Initializes a VARIANT structure with an array of 64-bit integer values.
///
/// Type: const LONGLONG*
/// Pointer to the source array of LONGLONG values.
///
///
/// Type: ULONG
/// The number of elements in the array pointed to by prgn.
/// The number of array elements.
///
///
/// Type: VARIANT*
/// When this function returns, contains the initialized VARIANT structure.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
///
/// Creates a VT_ARRAY | VT_I8 variant.
/// Examples
/// The following example, to be included as part of a larger program, demonstrates how to use InitVariantFromInt64Array.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-initvariantfromint64array PSSTDAPI
// InitVariantFromInt64Array( const LONGLONG *prgn, ULONG cElems, VARIANT *pvar );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "18e9c804-b5e4-4abe-adcd-eaa402c6c94a")]
public static extern HRESULT InitVariantFromInt64Array([In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] long[] prgn, uint cElems, out VARIANT pvar);
/// Initializes a VARIANT structure based on a string resource imbedded in an executable file.
///
/// Type: HINSTANCE
/// Handle to an instance of the module whose executable file contains the string resource.
///
///
/// Type: UINT
/// Integer identifier of the string to be loaded.
///
///
/// Type: VARIANT*
/// When this function returns, contains the initialized VARIANT structure.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
///
///
/// Creates a VT_BSTR variant. If the resource does not exist, this function initializes the VARIANT as VT_EMPTY and returns a
/// failure code.
///
/// Examples
/// The following example, to be included as part of a larger program, demonstrates how to use InitVariantFromResource.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-initvariantfromresource PSSTDAPI
// InitVariantFromResource( HINSTANCE hinst, UINT id, VARIANT *pvar );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "ae309a04-7b21-46ef-b481-2593dc162e19")]
public static extern HRESULT InitVariantFromResource(HINSTANCE hinst, uint id, out VARIANT pvar);
/// Initializes a VARIANT structure with an array of strings.
///
/// Type: PCWSTR*
/// Pointer to an array of strings.
///
///
/// Type: ULONG
/// The number of elements in the array pointed to by prgsz.
///
///
/// Type: VARIANT*
/// When this function returns, contains the initialized VARIANT structure.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
///
/// Creates a VT_ARRAY | VT_BSTR variant.
/// Examples
/// The following example, to be included as part of a larger program, demonstrates how to use InitVariantFromStringArray.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-initvariantfromstringarray PSSTDAPI
// InitVariantFromStringArray( PCWSTR *prgsz, ULONG cElems, VARIANT *pvar );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "f46cfc71-9e27-4ba1-8a32-5b279b628732")]
public static extern HRESULT InitVariantFromStringArray([In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1, ArraySubType = UnmanagedType.LPWStr)] string[] prgsz, uint cElems, out VARIANT pvar);
/// Initializes a VARIANT structure with a string stored in a STRRET structure.
///
/// Type: STRRET*
/// Pointer to a STRRET structure.
///
///
/// Type: PCUITEMID_CHILD
/// PIDL of the item whose details are being retrieved.
///
///
/// Type: VARIANT*
/// When this function returns, contains the initialized VARIANT structure.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
///
/// Creates a VT_BSTR variant.
/// Note This function frees the resources used for the STRRET contents.
/// Examples
/// The following example, to be included as part of a larger program, demonstrates how to use InitVariantFromStrRet.
/// // STRRET strret;
/// // PCUITEMID_CHILD pidl;
/// // Assume variables strret and pidl are initialized and valid.
/// VARIANT var;
/// HRESULT hr = InitVariantFromStrRet(strret, pidl, &var);
/// if (SUCCEEDED(hr))
/// {
/// // var now is valid and has type VT_BSTR.
/// VariantClear(&var);
/// }
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-initvariantfromstrret
// PSSTDAPI InitVariantFromStrRet( STRRET *pstrret, PCUITEMID_CHILD pidl, VARIANT *pvar );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "NF:propvarutil.InitVariantFromStrRet")]
public static extern HRESULT InitVariantFromStrRet([In] IntPtr pstrret, [In] IntPtr pidl, out VARIANT pvar);
/// Initializes a VARIANT structure with an array of unsigned 16-bit integer values.
///
/// Type: const USHORT*
/// Pointer to the source array of USHORT values.
///
///
/// Type: ULONG
/// The number of elements in the array pointed to by prgn.
///
///
/// Type: VARIANT*
/// When this function returns, contains the initialized VARIANT structure.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
///
/// Creates a VT_ARRAY | VT_UI2 variant.
/// Examples
/// The following example, to be included as part of a larger program, demonstrates how to use InitVariantFromUInt16Array.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-initvariantfromuint16array PSSTDAPI
// InitVariantFromUInt16Array( const USHORT *prgn, ULONG cElems, VARIANT *pvar );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "57fe1dd2-48a5-486e-a2cb-53cf0b8f96b0")]
public static extern HRESULT InitVariantFromUInt16Array([In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] ushort[] prgn, uint cElems, out VARIANT pvar);
/// Initializes a VARIANT structure with an array of unsigned 32-bit integer values.
///
/// Type: const ULONG*
/// Pointer to the source array of ULONG values.
///
///
/// Type: ULONG
/// The number of elements in the array pointed to by prgn.
///
///
/// Type: VARIANT*
/// When this function returns, contains the initialized VARIANT structure.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
///
/// Creates a VT_ARRAY | VT_UI4 variant.
/// Examples
/// The following example, to be included as part of a larger program, demonstrates how to use InitVariantFromUInt32Array.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-initvariantfromuint32array PSSTDAPI
// InitVariantFromUInt32Array( const ULONG *prgn, ULONG cElems, VARIANT *pvar );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "b08e61bc-8b76-4baf-acf7-9eb97e521b65")]
public static extern HRESULT InitVariantFromUInt32Array([In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] uint[] prgn, uint cElems, out VARIANT pvar);
/// Initializes a VARIANT structure with an array of unsigned 64-bit integer values.
///
/// Type: const ULONGLONG*
/// Pointer to the source array of ULONGLONG values.
///
///
/// Type: ULONG
/// The number of elements in the array pointed to by prgn.
///
///
/// Type: VARIANT*
/// When this function returns, contains the initialized VARIANT structure.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
///
/// Creates a VT_ARRAY | VT_UI8 variant.
/// Examples
/// The following example, to be included as part of a larger program, demonstrates how to use InitVariantFromUInt64Array.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-initvariantfromuint64array PSSTDAPI
// InitVariantFromUInt64Array( const ULONGLONG *prgn, ULONG cElems, VARIANT *pvar );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "67886e29-c3dd-4bfd-b53f-761c16daaf63")]
public static extern HRESULT InitVariantFromUInt64Array([In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] ulong[] prgn, uint cElems, ref object pvar);
/// Initializes a VARIANT structure with a value stored in another VARIANT structure.
///
/// Type: REFVARIANT
/// Reference to the source VARIANT structure.
///
///
/// Type: ULONG
/// Index of one of the source VARIANT structure elements.
///
///
/// Type: VARIANT*
/// When this function returns, contains the initialized VARIANT structure.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
///
/// This helper function works for VARIANT structures of the following types:
///
/// -
/// VT_BSTR
///
/// -
/// VT_BOOL
///
/// -
/// VT_I2
///
/// -
/// VT_I4
///
/// -
/// VT_I8
///
/// -
/// VT_U12
///
/// -
/// VT_U14
///
/// -
/// VT_U18
///
/// -
/// VT_DATE
///
/// -
/// VT_ARRAY | (any one of VT_BSTR, VT_BOOL, VT_I2, VT_I4, VT_I8, VT_U12, VT_U14, VT_U18, VT_DATE)
///
///
/// Additional types may be supported in the future.
///
/// This function extracts a single value from the source VARIANT structure and uses that value to initialize the output
/// VARIANT structure. The calling application must use VariantClear to free the VARIANT referred to by pvar when it is
/// no longer needed.
///
/// If the source VARIANT is an array, iElem must be less than the number of elements in the array.
/// If the source VARIANT has a single value, iElem must be 0.
/// If the source VARIANT is empty, this function always returns an error code.
/// You can use VariantGetElementCount to obtain the number of elements in the array or array.
/// Examples
///
/// The following example, to be included as part of a larger program, demonstrates how to use InitVariantFromVariantArrayElem in an
/// iteration statement to access the values in a VARIANT.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-initvariantfromvariantarrayelem PSSTDAPI
// InitVariantFromVariantArrayElem( REFVARIANT varIn, ULONG iElem, VARIANT *pvar );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "531731a5-7a13-49be-8512-5cf25c96ee35")]
public static extern HRESULT InitVariantFromVariantArrayElem(in VARIANT varIn, uint iElem, out VARIANT pvar);
/// Coerces a value stored as a structure to an equivalent value of a different variant type.
///
/// A pointer to a structure that, when this function returns successfully, receives the coerced value and
/// its new type.
///
///
/// A reference to the source structure that contains the value expressed as its original type.
///
/// Reserved, must be 0.
/// Specifies the new type for the value. See the tables below for recognized type names.
///
/// Returns S_OK if successful, or a standard COM error value otherwise. If the requested coercion is not possible, an error is returned.
///
[DllImport(Lib.PropSys, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb776514")]
public static extern HRESULT PropVariantChangeType([Out] PROPVARIANT ppropvarDest, [In] PROPVARIANT propvarSrc, PROPVAR_CHANGE_FLAGS flags, VARTYPE vt);
/// Compares two structures, based on default comparison units and settings.
/// Reference to the first structure.
/// Reference to the second structure.
///
///
/// -
/// Returns 1 if propvar1 is greater than propvar2
///
/// -
/// Returns 0 if propvar1 equals propvar2
///
/// -
/// Returns -1 if propvar1 is less than propvar2
///
///
///
[PInvokeData("Propvarutil.h", MSDNShortId = "bb776516")]
public static int PropVariantCompare(PROPVARIANT propvar1, PROPVARIANT propvar2)
{
return PropVariantCompareEx(propvar1, propvar2, PROPVAR_COMPARE_UNIT.PVCU_DEFAULT, PROPVAR_COMPARE_FLAGS.PVCF_DEFAULT);
}
/// Compares two structures, based on specified comparison units and flags.
/// Reference to the first structure.
/// Reference to the second structure.
/// Specifies, where appropriate, one of the comparison units defined in PROPVAR_COMPARE_UNIT.
/// Specifies one of the following:
///
///
/// -
/// Returns 1 if propvar1 is greater than propvar2
///
/// -
/// Returns 0 if propvar1 equals propvar2
///
/// -
/// Returns -1 if propvar1 is less than propvar2
///
///
///
[DllImport(Lib.PropSys, ExactSpelling = true, PreserveSig = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb776517")]
public static extern int PropVariantCompareEx(PROPVARIANT propvar1, PROPVARIANT propvar2, PROPVAR_COMPARE_UNIT unit, PROPVAR_COMPARE_FLAGS flags);
///
/// Extracts a single Boolean element from a PROPVARIANT structure of type , , or .
///
///
/// Type: REFPROPVARIANT
/// A reference to the source PROPVARIANT structure.
///
///
/// Type: ULONG
/// Specifies the vector or array index; otherwise, iElem must be 0.
///
///
/// Type: BOOL*
/// When this function returns, contains the extracted Boolean value.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
///
///
/// If the source PROPVARIANT structure has type , iElem must be 0. Otherwise iElem must be less than the number of elements in the
/// vector or array. You can use PropVariantGetElementCount to obtain the number of elements in the vector or array.
///
/// The following example uses this function to loop through the values in a PROPVARIANT structure.
/// Examples
///
// https://docs.microsoft.com/en-us/windows/desktop/api/propvarutil/nf-propvarutil-propvariantgetbooleanelem PSSTDAPI
// PropVariantGetBooleanElem( REFPROPVARIANT propvar, ULONG iElem, BOOL *pfVal );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "830dca70-1777-418d-b3ac-78028411700e")]
public static extern HRESULT PropVariantGetBooleanElem([In] PROPVARIANT propvar, uint iElem, [MarshalAs(UnmanagedType.Bool)] out bool pfVal);
///
/// Extracts a single double element from a PROPVARIANT structure of type , , or .
///
///
/// Type: REFPROPVARIANT
/// Reference to the source PROPVARIANT structure.
///
///
/// Type: ULONG
/// Specifies vector or array index; otherwise, iElem must be 0.
///
///
/// Type: DOUBLE*
/// When this function returns, contains the extracted double value.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
///
///
/// If the source PROPVARIANT has type , iElem must be 0. Otherwise iElem must be less than the number of elements in the vector or
/// array. You can use PropVariantGetElementCount to obtain the number of elements in the vector or array.
///
/// The following example uses this function to loop through the values in a PROPVARIANT structure.
/// Examples
///
// https://docs.microsoft.com/en-us/windows/desktop/api/propvarutil/nf-propvarutil-propvariantgetdoubleelem PSSTDAPI
// PropVariantGetDoubleElem( REFPROPVARIANT propvar, ULONG iElem, DOUBLE *pnVal );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "387e23df-bfbd-42c0-adef-dc53ba95a9f2")]
public static extern HRESULT PropVariantGetDoubleElem([In] PROPVARIANT propvar, uint iElem, out double pnVal);
/// Retrieves the element count of a structure.
/// Reference to the source structure.
///
/// Returns the element count of a VT_VECTOR or VT_ARRAY value: for single values, returns 1; for empty structures, returns 0.
///
[DllImport(Lib.PropSys, ExactSpelling = true, PreserveSig = true)]
[return: MarshalAs(UnmanagedType.I4)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb776522")]
public static extern int PropVariantGetElementCount([In] PROPVARIANT propVar);
///
///
/// Extracts a single FILETIME element from a PROPVARIANT structure of type VT_FILETIME, VT_VECTOR | VT_FILETIME, or VT_ARRAY | VT_FILETIME.
///
///
///
/// Type: REFPROPVARIANT
/// The source PROPVARIANT structure.
///
///
/// Type: ULONG
/// Specifies vector or array index; otherwise, this value must be 0.
///
///
/// Type: FILETIME*
/// When this function returns, contains the extracted filetime value.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
///
///
/// If the source PROPVARIANT has type VT_FILETIME, iElem must be 0; otherwise, iElem must be less than the number of elements in the
/// vector or array. You can use PropVariantGetElementCount to obtain the number of elements in the vector or array.
///
/// Examples
///
/// The following code example, to be included as part of a larger program, demonstrates how to use PropVariantGetFileTimeElem in an
/// iteration statement to access the values in PROPVARIANT.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/propvarutil/nf-propvarutil-propvariantgetfiletimeelem PSSTDAPI
// PropVariantGetFileTimeElem( REFPROPVARIANT propvar, ULONG iElem, FILETIME *pftVal );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "e38b16ed-84cb-4444-bfbd-1165595bc9b5")]
public static extern HRESULT PropVariantGetFileTimeElem([In] PROPVARIANT propvar, uint iElem, out FILETIME pftVal);
///
/// Extracts a single Int16 element from a PROPVARIANT structure of type VT_I2, VT_VECTOR | VT_I2, or VT_ARRAY | VT_I2.
///
///
/// Type: REFPROPVARIANT
/// Reference to the source PROPVARIANT structure.
///
///
/// Type: ULONG
/// The vector or array index; otherwise, this value must be 0.
///
///
/// Type: SHORT*
/// When this function returns, contains the extracted Int32 element value.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
///
/// This helper function works for PROPVARIANT structures of the following types.
///
/// -
/// VT_I2
///
/// -
/// VT_VECTOR | VT_I2
///
/// -
/// VT_ARRAY | VT_I2
///
///
///
/// If the source PROPVARIANT has type VT_I2, iElem must be 0. Otherwise, iElem must be less than the number of elements in the
/// vector or array. You can use PropVariantGetElementCount to obtain the number of elements in the vector or array.
///
/// Examples
///
/// The following example, to be included as part of a larger program, demonstrates how to use PropVariantGetInt16Elem with an
/// iteration statement to access the values in a PROPVARIANT.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/propvarutil/nf-propvarutil-propvariantgetint16elem PSSTDAPI
// PropVariantGetInt16Elem( REFPROPVARIANT propvar, ULONG iElem, SHORT *pnVal );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "1dbb6887-81c9-411d-9fce-c9e2f3479a43")]
public static extern HRESULT PropVariantGetInt16Elem([In] PROPVARIANT propvar, uint iElem, out short pnVal);
///
/// Extracts a single Int32 element from a PROPVARIANT of type VT_I4, VT_VECTOR | VT_I4, or VT_ARRAY | VT_I4.
///
///
/// Type: REFPROPVARIANT
/// Reference to the source PROPVARIANT structure.
///
///
/// Type: ULONG
/// The vector or array index; otherwise, iElem must be 0.
///
///
/// Type: LONG*
/// When this function, contains the extracted Int32 value.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
///
/// This helper function works for PROPVARIANT structures of the following types:
///
/// -
/// VT_I4
///
/// -
/// VT_VECTTOR | VT_I4
///
/// -
/// VT_ARRAY | VT_I4
///
///
///
/// If the source PROPVARIANT has type VT_I4, iElem must be 0. Otherwise, iElem must be less than the number of elements in the
/// vector or array. You can use PropVariantGetElementCount to obtain the number of elements in the vector or array.
///
/// Examples
///
/// The following example uses this PropVariantGetInt32Elem with an interation statement to access the values in a PROPVARIANT structure.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/propvarutil/nf-propvarutil-propvariantgetint32elem PSSTDAPI
// PropVariantGetInt32Elem( REFPROPVARIANT propvar, ULONG iElem, LONG *pnVal );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "de7dc6d4-d85a-44cb-8af7-840fd6e68d5c")]
public static extern HRESULT PropVariantGetInt32Elem([In] PROPVARIANT propvar, uint iElem, out int pnVal);
///
/// Extracts a single Int64 element from a PROPVARIANT structure of type VT_I8, VT_VECTOR | VT_I8, or VT_ARRAY | VT_I8.
///
///
/// Type: REFPROPVARIANT
/// Reference to the source PROPVARIANT structure.
///
///
/// Type: ULONG
/// The vector or array index; otherwise, iElem must be 0.
///
///
/// Type: LONGLONG*
/// When this function returns, contains the extracted Int64 value.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
///
/// This helper function works forPROPVARIANTstructures of the following types:
///
/// -
/// VT_I8
///
/// -
/// VT_VECTOR | VT_I8
///
/// -
/// VT_ARRAY | VT_I8
///
///
///
/// If the source PROPVARIANT has type VT_I8, iElem must be 0. Otherwise, iElem must be less than the number of elements in the
/// vector or array. You can use PropVariantGetElementCount to obtain the number of elements in the vector or array.
///
/// Examples
///
/// The following example, to be included as part of a larger program, demonstrates how to use PropVariantGetInt64Elem with an
/// iteration statement to access the values in a PROPVARIANT.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/propvarutil/nf-propvarutil-propvariantgetint64elem PSSTDAPI
// PropVariantGetInt64Elem( REFPROPVARIANT propvar, ULONG iElem, LONGLONG *pnVal );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "6dd7212a-587f-4f9e-a2e5-dbd2a9c15a5b")]
public static extern HRESULT PropVariantGetInt64Elem([In] PROPVARIANT propvar, uint iElem, out long pnVal);
///
///
/// Extracts a single Unicode string element from a PROPVARIANT structure of type VT_LPWSTR, VT_BSTR, VT_VECTOR | VT_LPWSTR,
/// VT_VECTOR | VT_BSTR, or VT_ARRAY | VT_BSTR.
///
///
///
/// Type: REFPROPVARIANT
/// Reference to a source PROPVARIANT structure.
///
///
/// Type: ULONG
/// The vector or array index; otherwise, iElem must be 0.
///
///
/// Type: PWSTR*
///
/// When this function returns, contains the extracted string value. The calling application is responsible for freeing this string
/// by calling CoTaskMemFree when it is no longer needed.
///
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
///
/// This helper function works for PROPVARIANT structures of the following types:
///
/// -
/// VT_LPWSTR
///
/// -
/// VT_BSTR
///
/// -
/// VT_VECTOR | VT_LPWSTR
///
/// -
/// VT_VECTOR | VT_BSTR
///
/// -
/// VT_ARRAY | VT_BSTR
///
///
///
/// If the source PROPVARIANT has type VT_LPWSTR or VT_BSTR, iElem must be 0. Otherwise iElem must be less than the number of
/// elements in the vector or array. You can use PropVariantGetElementCount to obtain the number of elements in the vector or array.
///
/// If a BSTR element has a NULL pointer, this function allocates an empty string.
/// Examples
///
/// The following code example, to be included as part of a larger program, demonstrates how to use PropVariantGetStringElem with an
/// iteration statement to access the values in a PROPVARIANT.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/propvarutil/nf-propvarutil-propvariantgetstringelem PSSTDAPI
// PropVariantGetStringElem( REFPROPVARIANT propvar, ULONG iElem, PWSTR *ppszVal );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "6e803d93-5b55-4b73-8e23-a584f5f91969")]
public static extern HRESULT PropVariantGetStringElem([In] PROPVARIANT propvar, uint iElem, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoTaskMemStringMarshaler))] out string ppszVal);
///
///
/// Extracts a single unsigned Int16 element from a PROPVARIANT structure of type VT_U12, VT_VECTOR | VT_U12, or VT_ARRAY | VT_U12.
///
///
///
/// Type: REFPROPVARIANT
/// Reference to the source PROPVARIANT structure.
///
///
/// Type: ULONG
/// The vector or array index; otherwise, iElem must be 0.
///
///
/// Type: USHORT*
/// When this function returns, contains the extracted element value.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
///
/// This helper function works for PROPVARIANT structures of the following types:
///
/// -
/// VT_UI2
///
/// -
/// VT_VECTOR | VT_UI2
///
/// -
/// VT_ARRAY | VT_UI2
///
///
///
/// If the source PROPVARIANT has type VT_UI2, iElem must be 0. Otherwise iElem must be less than the number of elements in the
/// vector or array. You can use PropVariantGetElementCount to obtain the number of elements in the vector or array.
///
/// Examples
///
/// The following example, to be included as part of a larger program, demonstrates how to use PropVariantGetUInt16Elem with an
/// iteration statement to access the values in a PROPVARIANT.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/propvarutil/nf-propvarutil-propvariantgetuint16elem PSSTDAPI
// PropVariantGetUInt16Elem( REFPROPVARIANT propvar, ULONG iElem, USHORT *pnVal );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "da50e35b-f17f-4de6-b2e7-5a885e2149e5")]
public static extern HRESULT PropVariantGetUInt16Elem([In] PROPVARIANT propvar, uint iElem, out ushort pnVal);
///
///
/// Extracts a single unsigned Int32 element from a PROPVARIANT structure of type VT_UI4, VT_VECTOR | VT_UI4, or VT_ARRAY | VT_UI4.
///
///
///
/// Type: REFPROPVARIANT
/// The source PROPVARIANT structure.
///
///
/// Type: ULONG
/// A vector or array index; otherwise, iElem must be 0.
///
///
/// Type: ULONG*
/// When this function returns, contains the extracted unsigned Int32 value.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
///
/// This helper function works for PROPVARIANT structures of the following types:
///
/// -
/// VT_UI4
///
/// -
/// VT_VECTOR | VT_UI4
///
/// -
/// VT_ARRAY | VT_UI4
///
///
///
/// If the source PROPVARIANT has type VT_UI4, iElem must be 0. Otherwise, iElem must be less than the number of elements in the
/// vector or array. You can use PropVariantGetElementCount to obtain the number of elements in the vector or array.
///
/// Examples
///
/// The following example, to be included as part of a larger program, demonstrates how to use PropVariantGetUInt32Elem with an
/// iteration statement to access the values in a PROPVARIANT.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/propvarutil/nf-propvarutil-propvariantgetuint32elem PSSTDAPI
// PropVariantGetUInt32Elem( REFPROPVARIANT propvar, ULONG iElem, ULONG *pnVal );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "b31975b6-d717-4e8d-bf5a-2ade96034031")]
public static extern HRESULT PropVariantGetUInt32Elem([In] PROPVARIANT propvar, uint iElem, out uint pnVal);
///
///
/// Extracts a single unsigned Int64 element from a PROPVARIANT structure of type VT_UI8, VT_VECTOR | VT_UI8, or VT_ARRAY | VT_UI8.
///
///
///
/// Type: REFPROPVARIANT
/// The source PROPVARIANT structure.
///
///
/// Type: ULONG
/// The vector or array index; otherwise, iElem must be 0.
///
///
/// Type: ULONGLONG*
/// When this function returns, contains the extracted Int64 value.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
///
/// This helper function works for PROPVARIANT structures of the following types:
///
/// -
/// VT_UI8
///
/// -
/// VT_VECTOR | VT_UI8
///
/// -
/// VT_ARRAY | VT_UI8
///
///
///
/// If the source PROPVARIANT has type VT_UI8, iElem must be 0. Otherwise iElem must be less than the number of elements in the
/// vector or array. You can use PropVariantGetElementCount to obtain the number of elements in the vector or array.
///
/// Examples
///
/// The following example, to be included as part of a larger program, demonstrates how to use PropVariantGetUInt64Elem with an
/// iteration statement to access the values in a PROPVARIANT.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/propvarutil/nf-propvarutil-propvariantgetuint64elem PSSTDAPI
// PropVariantGetUInt64Elem( REFPROPVARIANT propvar, ULONG iElem, ULONGLONG *pnVal );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "35955104-b567-4c4f-850a-0a4778673ce8")]
public static extern HRESULT PropVariantGetUInt64Elem([In] PROPVARIANT propvar, uint iElem, out ulong pnVal);
///
/// Extracts a Boolean property value of a structure. If no value can be extracted, then a default value is assigned.
///
/// Reference to the source structure.
/// When this function returns, contains the extracted property value if one exists; otherwise, contains FALSE.
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
[DllImport(Lib.PropSys, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb776531")]
public static extern HRESULT PropVariantToBoolean([In] PROPVARIANT propVar, [MarshalAs(UnmanagedType.Bool)] out bool pfRet);
///
/// Extracts a Boolean vector from a PROPVARIANT structure.
///
///
/// Type: REFPROPVARIANT
/// Reference to a source PROPVARIANT structure.
///
///
/// Type: BOOL*
///
/// Points to a buffer that contains crgf BOOL values. When this function returns, the buffer has been initialized with pcElem
/// Boolean elements extracted from the source PROPVARIANT structure.
///
///
///
/// Type: ULONG
/// Number of elements in the buffer pointed to by prgf.
///
///
/// Type: ULONG*
/// When this function returns, contains the count of Boolean elements extracted from source PROPVARIANT structure.
///
///
/// Type: HRESULT
/// This function can return one of these values.
///
///
/// Return code
/// Description
///
/// -
/// S_OK
/// Returns S_OK if successful, or an error value otherwise.
///
/// -
/// TYPE_E_BUFFERTOOSMALL
/// The source PROPVARIANT contained more than crgf values. The buffer pointed to by prgf.
///
/// -
/// E_INVALIDARG
/// The PROPVARIANT was not of the appropriate type.
///
///
///
///
///
/// This helper function is used when the calling application expects a PROPVARIANT to hold a Boolean vector value with a fixed
/// number of elements.
///
///
/// If the source PROPVARIANT has type VT_VECTOR | VT_BOOL or VT_ARRAY | VT_BOOL, this helper function extracts up to crgf Boolean
/// values an places them into the buffer pointed to by prgf. If the PROPVARIANT contains more elements than will fit into the
/// prgf buffer, this function returns an error and sets pcElem to 0.
///
/// Examples
///
/// The following example, to be included as part of a larger program, demonstrates how to use PropVariantToBooleanVector to access a
/// Boolean vector stored in a PROPVARIANT.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/propvarutil/nf-propvarutil-propvarianttobooleanvector PSSTDAPI
// PropVariantToBooleanVector( REFPROPVARIANT propvar, BOOL *prgf, ULONG crgf, ULONG *pcElem );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "93ccd129-4fa4-40f3-96f3-b87b50414b0a")]
public static extern HRESULT PropVariantToBooleanVector([In] PROPVARIANT propvar, [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2, ArraySubType = UnmanagedType.Bool)] bool[] prgf, uint crgf, out uint pcElem);
/// Extracts data from a structure into a newly allocated Boolean vector.
/// Reference to the source structure.
///
/// When this function returns, contains a pointer to a vector of Boolean values extracted from the source structure.
///
///
/// When this function returns, contains the count of Boolean elements extracted from the source structure.
///
///
/// Returns S_OK if successful, or an error value otherwise. E_INVALIDARG indicates that the was not of the
/// appropriate type.
///
[DllImport(Lib.PropSys, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb776533")]
public static extern HRESULT PropVariantToBooleanVectorAlloc([In] PROPVARIANT propVar, out SafeCoTaskMemHandle pprgf, out uint pcElem);
///
///
/// Extracts the Boolean property value of a PROPVARIANT structure. If no value exists, then the specified default value is returned.
///
///
///
/// Type: REFPROPVARIANT
/// Reference to a source PROPVARIANT structure.
///
///
/// Type: BOOL
/// Specifies the default property value, for use where no value currently exists.
///
///
/// Type: BOOL
/// The extracted Boolean value or the default value.
///
///
///
/// This helper function is used in places where the calling application expects a PROPVARIANT to hold a Boolean value and would like
/// to use a default value if it does not. For instance, an application that obtains values from a property store can use this to
/// safely extract the Boolean value for Boolean properties.
///
///
/// If the source PROPVARIANT has type VT_BOOL, this helper function extracts the Boolean value. Otherwise, it attempts to
/// convert the value in the PROPVARIANT structure into a Boolean. If the source PROPVARIANT has type VT_EMPTY
/// or a conversion is not possible, then PropVariantToBooleanWithDefault returns the default provided by fDefault. See
/// PropVariantChangeType for a list of possible conversions.
///
/// Examples
///
/// The following example, to be included as part of a larger program, demonstrates how to use PropVariantToBooleanWithDefault to
/// access a Boolean value in a PROPVARIANT.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/propvarutil/nf-propvarutil-propvarianttobooleanwithdefault PSSTDAPI_(BOOL)
// PropVariantToBooleanWithDefault( REFPROPVARIANT propvarIn, BOOL fDefault );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "223767a7-a4de-4e7e-ad8b-2a6bdcea0a47")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool PropVariantToBooleanWithDefault([In] PROPVARIANT propvarIn, [MarshalAs(UnmanagedType.Bool)] bool fDefault);
/// Extracts the BSTR property value of a structure.
/// Reference to the source structure.
/// Pointer to the extracted property value if one exists; otherwise, contains an empty string.
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
[DllImport(Lib.PropSys, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb776535")]
public static extern HRESULT PropVariantToBSTR([In] PROPVARIANT propVar, [MarshalAs(UnmanagedType.BStr)] out string pbstrOut);
/// Extracts the buffer value from a structure of type VT_VECTOR | VT_UI1 or VT_ARRRAY | VT_UI1.
/// Reference to the source structure.
///
/// Pointer to a buffer of length cb bytes. When this function returns, contains the first cb bytes of the extracted buffer value.
///
/// The buffer length, in bytes.
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
[DllImport(Lib.PropSys, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb776536")]
public static extern HRESULT PropVariantToBuffer([In] PROPVARIANT propVar, [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] byte[] pv, uint cb);
/// Extracts double value from a structure.
/// Reference to the source structure.
///
/// When this function returns, contains the extracted property value if one exists; otherwise, contains 0.0.
///
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
[DllImport(Lib.PropSys, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb776538")]
public static extern HRESULT PropVariantToDouble([In] PROPVARIANT propVar, [MarshalAs(UnmanagedType.R8)] out double pdblRet);
///
/// Extracts a vector of doubles from a PROPVARIANT structure.
///
///
/// Type: REFPROPVARIANT
/// Reference to a source PROPVARIANT structure.
///
///
/// Type: DOUBLE*
///
/// Points to a buffer containing crgn DOUBLE values. When this function returns, the buffer has been initialized with pcElem double
/// elements extracted from the source PROPVARIANT structure.
///
///
///
/// Type: ULONG
/// Size in elements of the buffer pointed to by prgn.
///
///
/// Type: ULONG*
/// When this function returns, contains the count of double elements extracted from the source PROPVARIANT structure.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
///
///
/// This helper function is used in places where the calling application expects a PROPVARIANT to hold a double vector value with a
/// fixed number of elements.
///
///
/// If the source PROPVARIANT has type VT_VECTOR | VT_R8 or VT_ARRAY | VT_R8, this helper function extracts up to crgn double values
/// and places them into the buffer pointed to by prgn. If the PROPVARIANT contains more elements than will fit into the prgn
/// buffer, this function returns an error and sets pcElem to 0.
///
/// Examples
///
// https://docs.microsoft.com/en-us/windows/desktop/api/propvarutil/nf-propvarutil-propvarianttodoublevector PSSTDAPI
// PropVariantToDoubleVector( REFPROPVARIANT propvar, DOUBLE *prgn, ULONG crgn, ULONG *pcElem );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "2d90bf96-8a3f-4949-8480-bb75f0deeb2e")]
public static extern HRESULT PropVariantToDoubleVector([In] PROPVARIANT propvar, [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] double[] prgn, uint crgn, out uint pcElem);
/// Extracts data from a structure into a newly-allocated double vector.
/// Reference to the source structure.
///
/// When this function returns, contains a pointer to a vector of double values extracted from the source structure.
///
///
/// When this function returns, contains the count of double elements extracted from the source structure.
///
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
[DllImport(Lib.PropSys, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb776540")]
public static extern HRESULT PropVariantToDoubleVectorAlloc([In] PROPVARIANT propVar, out SafeCoTaskMemHandle pprgf, out uint pcElem);
///
/// Extracts a double property value of a PROPVARIANT structure. If no value exists, then the specified default value is returned.
///
///
/// Type: REFPROPVARIANT
/// Reference to a source PROPVARIANT structure.
///
///
/// Type: DOUBLE
/// Specifies default property value, for use where no value currently exists.
///
///
/// Type: DOUBLE
/// Returns extracted double value, or default.
///
///
///
/// This helper function is used in places where the calling application expects a PROPVARIANT to hold a double value and would like
/// to use a default value if it does not. For instance, an application obtaining values from a property store can use this to safely
/// extract the double value for double properties.
///
///
/// If the source PROPVARIANT has type VT_R8, this helper function extracts the double value. Otherwise, it attempts to
/// convert the value in the PROPVARIANT structure into a double. If the source PROPVARIANT has type VT_EMPTY or
/// a conversion is not possible, then PropVariantToDoubleWithDefault will return the default provided by dblDefault. See
/// PropVariantChangeType for a list of possible conversions.
///
/// Examples
///
// https://docs.microsoft.com/en-us/windows/desktop/api/propvarutil/nf-propvarutil-propvarianttodoublewithdefault PSSTDAPI_(DOUBLE)
// PropVariantToDoubleWithDefault( REFPROPVARIANT propvarIn, DOUBLE dblDefault );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "81584e13-0ef7-47ce-b78f-b4a79712ff1e")]
public static extern double PropVariantToDoubleWithDefault([In] PROPVARIANT propvarIn, double dblDefault);
/// Extracts the structure from a structure.
/// Reference to the source structure.
/// Specifies one of the time flags.
/// When this function returns, contains the extracted structure.
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
[DllImport(Lib.PropSys, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb776542")]
public static extern HRESULT PropVariantToFileTime([In] PROPVARIANT propVar, PSTIME_FLAGS pstfOut, out FILETIME pftOut);
///
/// Extracts data from a PROPVARIANT structure into a FILETIME vector.
///
///
/// Type: REFPROPVARIANT
/// Reference to a source PROPVARIANT structure.
///
///
/// Type: FILETIME*
///
/// Points to a buffer containing crgft FILETIME values. When this function returns, the buffer has been initialized with pcElem
/// FILETIME elements extracted from the source PROPVARIANT structure.
///
///
///
/// Type: ULONG
/// Size in elements of the buffer pointed to by prgft.
///
///
/// Type: ULONG*
/// When this function returns, contains the count of FILETIME elements extracted from the source PROPVARIANT structure.
///
///
/// Type: HRESULT
/// Returns one of the following values.
///
///
/// Return code
/// Description
///
/// -
/// S_OK
/// Returns S_OK if successful, or an error value otherwise.
///
/// -
/// TYPE_E_BUFFERTOOSMALL
/// The source PROPVARIANT contained more than crgn values. The buffer pointed to by prgft.
///
/// -
/// E_INVALIDARG
/// The PROPVARIANT was not of the appropriate type.
///
///
///
///
///
/// This helper function is used in places where the calling application expects a PROPVARIANT to hold a filetime vector value with a
/// fixed number of elements.
///
///
/// If the source PROPVARIANT has type VT_VECTOR | VT_FILETIME, this helper function extracts up to crgft FILETIME values and places
/// them into the buffer pointed to by prgft. If the PROPVARIANT contains more elements than will fit into the prgft buffer,
/// this function returns an error and sets pcElem to 0.
///
/// The output FILETIMEs will use the same time zone as the source FILETIMEs.
/// Examples
///
/// The following example, to be included as part of a larger program, demonstrates how to use PropVariantToFileTimeVector to access
/// a FILETIME vector value in a PROPVARIANT.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/propvarutil/nf-propvarutil-propvarianttofiletimevector PSSTDAPI
// PropVariantToFileTimeVector( REFPROPVARIANT propvar, FILETIME *prgft, ULONG crgft, ULONG *pcElem );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "ef665f50-3f3b-47db-9133-490305da5341")]
public static extern HRESULT PropVariantToFileTimeVector([In] PROPVARIANT propvar, [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] FILETIME[] prgft, uint crgft, out uint pcElem);
/// Extracts data from a structure into a newly-allocated vector.
/// Reference to the source structure.
///
/// When this function returns, contains a pointer to a vector of values extracted from the source
/// structure.
///
///
/// When this function returns, contains the count of elements extracted from source structure.
///
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
[DllImport(Lib.PropSys, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb776544")]
public static extern HRESULT PropVariantToFileTimeVectorAlloc([In] PROPVARIANT propVar, out SafeCoTaskMemHandle pprgf, out uint pcElem);
/// Extracts a GUID value from a structure.
/// Reference to the source structure.
/// When this function returns, contains the extracted property value if one exists.
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
[DllImport(Lib.PropSys, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb776545")]
public static extern HRESULT PropVariantToGUID([In] PROPVARIANT propVar, out Guid pguid);
/// Extracts an Int16 property value of a structure.
/// Reference to the source structure.
/// When this function returns, contains the extracted property value if one exists; otherwise, 0.
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
[DllImport(Lib.PropSys, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb776546")]
public static extern HRESULT PropVariantToInt16([In] PROPVARIANT propVar, [MarshalAs(UnmanagedType.I2)] out short piRet);
///
/// Extracts a vector of Int16 values from a PROPVARIANT structure.
///
///
/// Type: REFPROPVARIANT
/// Reference to a source PROPVARIANT structure.
///
///
/// Type: SHORT*
///
/// Points to a buffer containing crgn SHORT values. When this function returns, the buffer has been initialized with pcElem SHORT
/// elements extracted from the source PROPVARIANT structure.
///
///
///
/// Type: ULONG
/// Size of the buffer pointed to by prgn in elements.
///
///
/// Type: ULONG*
/// When this function returns, contains the count of Int16 elements extracted from source PROPVARIANT structure.
///
///
/// Type: HRESULT
/// This function can return one of these values.
///
///
/// Return code
/// Description
///
/// -
/// S_OK
/// Returns S_OK if successful, or an error value otherwise.
///
/// -
/// TYPE_E_BUFFERTOOSMALL
/// The source PROPVARIANT contained more than crgn values. The buffer pointed to by prgn.
///
/// -
/// E_INVALIDARG
/// ThePROPVARIANTwas not of the appropriate type.
///
///
///
///
///
/// This helper function is used in places where the calling application expects a PROPVARIANT to hold an Int16 vector value
/// with a fixed number of elements.
///
///
/// If the source PROPVARIANT has type VT_VECTOR | VT_I2 or VT_ARRAY | VT_I2, this helper function extracts up to crgn Int16 values
/// and places them into the buffer pointed to by prgn. If the PROPVARIANT contains more elements than will fit into the prgn
/// buffer, this function returns an error and sets pcElem to 0.
///
/// Examples
///
// https://docs.microsoft.com/en-us/windows/desktop/api/propvarutil/nf-propvarutil-propvarianttoint16vector PSSTDAPI
// PropVariantToInt16Vector( REFPROPVARIANT propvar, SHORT *prgn, ULONG crgn, ULONG *pcElem );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "33240552-7caa-4114-aad6-7341551b1fbe")]
public static extern HRESULT PropVariantToInt16Vector([In] PROPVARIANT propvar, [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] short[] prgn, uint crgn, out uint pcElem);
/// Extracts data from a structure into a newly allocated Int16 vector.
/// Reference to the source structure.
///
/// When this function returns, contains a pointer to a vector of Int16 values extracted from the source structure.
///
///
/// When this function returns, contains the count of Int16 elements extracted from source structure.
///
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
[DllImport(Lib.PropSys, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb776548")]
public static extern HRESULT PropVariantToInt16VectorAlloc([In] PROPVARIANT propVar, out SafeCoTaskMemHandle pprgf, out uint pcElem);
///
///
/// Extracts the Int16 property value of a PROPVARIANT structure. If no value currently exists, then specified default value is returned.
///
///
///
/// Type: REFPROPVARIANT
/// Reference to a source PROPVARIANT structure.
///
///
/// Type: SHORT
/// Specifies default property value, for use where no value currently exists.
///
///
/// Type: SHORT
/// Returns the extracted short value, or default.
///
///
///
/// This helper function is used in places where the calling application expects a PROPVARIANT to hold an Int16 value and
/// would like to use a default value if it does not. For instance, an application obtaining values from a property store can use
/// this to safely extract the SHORT value for Int16 properties.
///
///
/// If the source PROPVARIANT has type VT_I2, this helper function extracts the Int16 value. Otherwise, it attempts to
/// convert the value in the PROPVARIANT structure into a SHORT. If the source PROPVARIANT has type
/// VT_EMPTY or a conversion is not possible, then PropVariantToInt16WithDefault will return the default provided by iDefault.
/// See PropVariantChangeType for a list of possible conversions.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/propvarutil/nf-propvarutil-propvarianttoint16withdefault PSSTDAPI_(SHORT)
// PropVariantToInt16WithDefault( REFPROPVARIANT propvarIn, SHORT iDefault );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "51221281-6e06-49f4-83c0-7330f2a6d67e")]
public static extern short PropVariantToInt16WithDefault([In] PROPVARIANT propvarIn, short iDefault);
/// Extracts an Int32 property value of a structure.
/// Reference to the source structure.
/// When this function returns, contains the extracted property value if one exists; otherwise, 0.
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
[DllImport(Lib.PropSys, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb776550")]
public static extern HRESULT PropVariantToInt32([In] PROPVARIANT propVar, [MarshalAs(UnmanagedType.I4)] out int plRet);
///
/// Extracts a vector of long values from a PROPVARIANT structure.
///
///
/// Type: REFPROPVARIANT
/// Reference to a source PROPVARIANT structure.
///
///
/// Type: LONG*
///
/// Points to a buffer containing crgn LONG values. When this function returns, the buffer has been initialized with pcElem
/// LONG elements extracted from the source PROPVARIANT.
///
///
///
/// Type: ULONG
/// Size of the buffer pointed to by prgn in elements.
///
///
/// Type: ULONG*
/// When this function returns, contains the count of LONG elements extracted from source PROPVARIANT structure.
///
///
/// Type: HRESULT
/// This function can return one of these values.
///
///
/// Return code
/// Description
///
/// -
/// S_OK
/// Returns S_OK if successful, or an error value otherwise.
///
/// -
/// TYPE_E_BUFFERTOOSMALL
/// The source PROPVARIANT contained more than crgn values. The buffer pointed to by prgn.
///
/// -
/// E_INVALIDARG
/// The PROPVARIANT was not of the appropriate type.
///
///
///
///
///
/// This helper function is used in places where the calling application expects a PROPVARIANT to hold an vector of LONG
/// values with a fixed number of elements.
///
///
/// If the source PROPVARIANT has type VT_VECTOR | VT_I4 or VT_ARRAY | VT_I4, this helper function
/// extracts up to crgn LONG values and places them into the buffer pointed to by prgn. If the PROPVARIANT contains
/// more elements than will fit into the prgn buffer, this function returns an error and sets pcElem to 0.
///
/// Examples
///
/// The following example, to be included as part of a larger program, demonstrates how to use PropVariantToInt32Vector to access an
/// Int32 vector value in a PROPVARIANT.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/propvarutil/nf-propvarutil-propvarianttoint32vector PSSTDAPI
// PropVariantToInt32Vector( REFPROPVARIANT propvar, LONG *prgn, ULONG crgn, ULONG *pcElem );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "771fa1d7-c648-49d4-a6a2-5aa23f8c20b7")]
public static extern HRESULT PropVariantToInt32Vector([In] PROPVARIANT propvar, [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] int[] prgn, uint crgn, out uint pcElem);
/// Extracts data from a structure into a newly allocated Int32 vector.
/// Reference to the source structure.
///
/// When this function returns, contains a pointer to a vector of Int32 values extracted from the source structure.
///
///
/// When this function returns, contains the count of Int32 elements extracted from source structure.
///
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
[DllImport(Lib.PropSys, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb776552")]
public static extern HRESULT PropVariantToInt32VectorAlloc([In] PROPVARIANT propVar, out SafeCoTaskMemHandle pprgf, out uint pcElem);
///
///
/// Extracts an Int32 value from a PROPVARIANT structure. If no value currently exists, then the specified default value is returned.
///
///
///
/// Type: REFPROPVARIANT
/// Reference to a source PROPVARIANT structure.
///
///
/// Type: LONG
/// Specifies a default property value, for use where no value currently exists.
///
///
/// Type: LONG
/// Returns extracted LONG value, or default.
///
///
///
/// This helper function is used in places where the calling application expects a PROPVARIANT to hold a LONG value and would
/// like to use a default value if it does not. For instance, an application obtaining values from a property store can use this to
/// safely extract the LONG value for Int32 properties.
///
///
/// If the source PROPVARIANT has type VT_I4, this helper function extracts the LONG value. Otherwise, it attempts to
/// convert the value in the PROPVARIANT structure into a LONG. If the source PROPVARIANT has type
/// VT_EMPTY or a conversion is not possible, then PropVariantToInt32WithDefault will return the default provided by lDefault.
/// See PropVariantChangeType for a list of possible conversions.
///
/// Examples
///
/// The following example, to be included as part of a larger program, demonstrates how to use PropVariantToInt32WithDefault to
/// access a LONG value in a PROPVARIANT.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/propvarutil/nf-propvarutil-propvarianttoint32withdefault PSSTDAPI_(LONG)
// PropVariantToInt32WithDefault( REFPROPVARIANT propvarIn, LONG lDefault );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "1d014cad-a9a5-4a58-855e-21c6d3ba6dcd")]
public static extern int PropVariantToInt32WithDefault([In] PROPVARIANT propvarIn, int lDefault);
/// Extracts an Int64 property value of a structure.
/// Reference to the source structure.
/// When this function returns, contains the extracted property value if one exists; otherwise, 0.
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
[DllImport(Lib.PropSys, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb776554")]
public static extern HRESULT PropVariantToInt64([In] PROPVARIANT propVar, [MarshalAs(UnmanagedType.I8)] out long pllRet);
///
/// Extracts data from a PROPVARIANT structure into an Int64 vector.
///
///
/// Type: REFPROPVARIANT
/// Reference to a source PROPVARIANT structure.
///
///
/// Type: LONGLONG*
///
/// Points to a buffer containing crgn LONGLONG values. When this function returns, the buffer has been initialized with
/// pcElem LONGLONG elements extracted from the source PROPVARIANT.
///
///
///
/// Type: ULONG
/// Size of the buffer pointed to by prgn in elements.
///
///
/// Type: ULONG*
/// When this function returns, contains the count of LONGLONG values extracted from the source PROPVARIANT structure.
///
///
/// Type: HRESULT
/// This function can return one of these values.
///
///
/// Return code
/// Description
///
/// -
/// S_OK
/// Returns S_OK if successful, or an error value otherwise.
///
/// -
/// TYPE_E_BUFFERTOOSMALL
/// The source PROPVARIANT contained more than crgn values. The buffer pointed to by prgn.
///
/// -
/// E_INVALIDARG
/// The PROPVARIANT was not of the appropriate type
///
///
///
///
///
/// This helper function is used in places where the calling application expects a PROPVARIANT to hold an vector of LONGLONG
/// values with a fixed number of elements.
///
///
/// If the source PROPVARIANT has type VT_VECTOR | VT_I8 or VT_ARRAY | VT_I8, this helper function
/// extracts up to crgn LONGLONG values and places them into the buffer pointed to by prgn. If the PROPVARIANT contains
/// more elements than will fit into the prgn buffer, this function returns an error and sets pcElem to 0.
///
/// Examples
///
/// The following example, to be included as part of a larger program, demonstrates how to use PropVariantToInt64Vector to access an
/// Int64 vector value in a PROPVARIANT.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/propvarutil/nf-propvarutil-propvarianttoint64vector PSSTDAPI
// PropVariantToInt64Vector( REFPROPVARIANT propvar, LONGLONG *prgn, ULONG crgn, ULONG *pcElem );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "cda5589a-726f-4e43-aec4-bb7a7ca62b1a")]
public static extern HRESULT PropVariantToInt64Vector([In] PROPVARIANT propvar, [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] long[] prgn, uint crgn, out uint pcElem);
/// Extracts data from a structure into a newly allocated Int64 vector.
/// Reference to the source structure.
///
/// When this function returns, contains a pointer to a vector of Int64 values extracted from the source structure.
///
///
/// When this function returns, contains the count of Int64 elements extracted from source structure.
///
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
[DllImport(Lib.PropSys, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb776557")]
public static extern HRESULT PropVariantToInt64VectorAlloc([In] PROPVARIANT propVar, out SafeCoTaskMemHandle pprgf, out uint pcElem);
///
///
/// Extracts the Int64 property value of a PROPVARIANT structure. If no value exists, then specified default value is returned.
///
///
///
/// Type: REFPROPVARIANT
/// Reference to a source PROPVARIANT structure.
///
///
/// Type: LONGLONG
/// Specifies a default property value, for use where no value currently exists.
///
///
/// Type: LONGLONG
/// Returns the extracted LONGLONG value, or default.
///
///
///
/// This helper function is used in places where the calling application expects a PROPVARIANT to hold a LONGLONG value and
/// would like to use a default value if it does not. For instance, an application obtaining values from a property store can use
/// this to safely extract the LONGLONG value for Int64 properties.
///
///
/// If the source PROPVARIANT has type VT_I8, this helper function extracts the LONGLONG value. Otherwise, it attempts
/// to convert the value in the PROPVARIANT structure into a LONGLONG. If the source PROPVARIANT has type
/// VT_EMPTY or a conversion is not possible, then PropVariantToInt64WithDefault will return the default provided by
/// llDefault. See PropVariantChangeType for a list of possible conversions.
///
/// Examples
///
/// The following example, to be included as part of a larger program, demonstrates how to use PropVariantToInt64WithDefault to
/// access a LONGLONG value in a PROPVARIANT.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/propvarutil/nf-propvarutil-propvarianttoint64withdefault PSSTDAPI_(LONGLONG)
// PropVariantToInt64WithDefault( REFPROPVARIANT propvarIn, LONGLONG llDefault );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "6a051235-3e32-40d3-a17e-efc571592dae")]
public static extern long PropVariantToInt64WithDefault([In] PROPVARIANT propvarIn, long llDefault);
///
/// Extracts a string value from a PROPVARIANT structure.
///
///
/// Type: REFPROPVARIANT
/// Reference to a source PROPVARIANT structure.
///
///
/// Type: PWSTR
///
/// Points to a string buffer. When this function returns, the buffer is initialized with a NULL terminated Unicode string value.
///
///
///
/// Type: UINT
/// Size of the buffer pointed to by psz, in characters.
///
///
/// Type: HRESULT
/// This function can return one of these values.
///
///
/// Return code
/// Description
///
/// -
/// S_OK
/// The value was extracted and the result buffer was NULL terminated.
///
/// -
/// STRSAFE_E_INSUFFICIENT_BUFFER
///
/// The copy operation failed due to insufficient buffer space. The destination buffer contains a truncated, null-terminated version
/// of the intended result. In situations where truncation is acceptable, this may not necessarily be seen as a failure condition.
///
///
/// -
/// Some other error value
/// The extraction failed for some other reason.
///
///
///
///
///
/// This helper function is used in places where the calling application expects a PROPVARIANT to hold a string value. For instance,
/// an application obtaining values from a property store can use this to safely extract a string value for string properties.
///
///
/// If the source PROPVARIANT has type VT_LPWSTR or VT_BSTR, this function extracts the string and places it into the provided
/// buffer. Otherwise, it attempts to convert the value in the PROPVARIANT structure into a string. If a conversion is not
/// possible, PropVariantToString will return a failure code and set psz to '\0'. See PropVariantChangeType for a list of possible
/// conversions. Of note, VT_EMPTY is successfully converted to "".
///
///
/// In addition to the terminating NULL, at most cch-1 characters are written into the buffer pointed to by psz. If the value
/// in the source PROPVARIANT is longer than will fit into the buffer, a truncated NULL Terminated copy of the string is
/// written to the buffer and this function returns STRSAFE_E_INSUFFICIENT_BUFFER. The resulting string will always be
/// NULL terminated.
///
/// In addition to the conversions provided by PropVariantChangeType, the following special cases apply to PropVariantToString.
///
/// -
///
/// Vector-valued PROPVARIANTs are converted to strings by separating each element with using "; ". For example, PropVariantToString
/// converts a vector of 3 integers, {3, 1, 4}, to the string "3; 1; 4". The semicolon is independent of the current locale.
///
///
/// -
///
/// VT_BLOB, VT_STREAM, VT_STREAMED_OBJECT, and VT_UNKNOWN values are converted to strings using an unsupported encoding. It is not
/// possible to decode strings created in this way and the format may change in the future.
///
///
///
/// Examples
///
/// The following example, to be included as part of a larger program, demonstrates how to use PropVariantToString to access a string
/// value in a PROPVARIANT.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/propvarutil/nf-propvarutil-propvarianttostring PSSTDAPI PropVariantToString(
// REFPROPVARIANT propvar, PWSTR psz, UINT cch );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "d545dc12-a780-4d95-8660-13b3f65725f9")]
public static extern HRESULT PropVariantToString([In] PROPVARIANT propvar, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder psz, uint cch);
/// Extracts a string property value from a structure.
/// Reference to the source structure.
/// When this function returns, contains a pointer to the extracted property value if one exists.
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
[DllImport(Lib.PropSys, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb776560")]
public static extern HRESULT PropVariantToStringAlloc([In] PROPVARIANT propVar, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoTaskMemStringMarshaler))] out string ppszOut);
///
/// Extracts a vector of strings from a PROPVARIANT structure.
///
///
/// Type: REFPROPVARIANT
/// Reference to a source PROPVARIANT structure.
///
///
/// Type: PWSTR*
///
/// Pointer to a vector of string pointers. When this function returns, the buffer has been initialized with pcElem elements pointing
/// to newly allocated strings containing the data extracted from the source PROPVARIANT.
///
///
///
/// Type: ULONG
/// Size of the buffer pointed to by prgsz, in elements.
///
///
/// Type: ULONG*
/// When this function returns, contains the count of strings extracted from source PROPVARIANT structure.
///
///
/// Type: HRESULT
/// This function can return one of these values.
///
///
/// Return code
/// Description
///
/// -
/// S_OK
/// Returns S_OK if successful, or an error value otherwise.
///
/// -
/// TYPE_E_BUFFERTOOSMALL
/// The sourcePROPVARIANTcontained more than crgsz values. The buffer pointed to by prgsz.
///
/// -
/// E_INVALIDARG
/// ThePROPVARIANTwas not of the appropriate type.
///
///
///
///
///
/// This helper function is used in places where the calling application expects a PROPVARIANT to hold an vector of string values
/// with a fixed number of elements.
///
/// This function works for the following PROPVARIANT types:
///
/// -
/// VT_VECTOR | VT_LPWSTR
///
/// -
/// VT_VECTOR | VT_BSTR
///
/// -
/// VT_ARRAY | VT_BSTR
///
///
///
/// If the source PROPVARIANT has a supported type, this helper function extracts up to crgsz string values and places an allocated
/// copy of each into the buffer pointed to by prgsz. If the PROPVARIANT contains more elements than will fit into the prgsz
/// buffer, this function returns an error and sets pcElem to 0.
///
///
/// Since each string in pointed to by the output buffer has been newly allocated, the calling application is responsible for using
/// CoTaskMemFree to free each string in the output buffer when they are no longer needed.
///
///
/// If a BSTR in the source PROPVARIANT is NULL, it is converted to a newly allocated string containing "" in the output.
///
/// Examples
///
// https://docs.microsoft.com/en-us/windows/desktop/api/propvarutil/nf-propvarutil-propvarianttostringvector PSSTDAPI
// PropVariantToStringVector( REFPROPVARIANT propvar, PWSTR *prgsz, ULONG crgsz, ULONG *pcElem );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "6618ee02-1939-4c9c-8690-a8cd5d668cdb")]
public static extern HRESULT PropVariantToStringVector([In] PROPVARIANT propvar, IntPtr prgsz, uint crgsz, out uint pcElem);
///
/// Extracts a vector of strings from a PROPVARIANT structure.
///
///
/// Type: REFPROPVARIANT
/// Reference to a source PROPVARIANT structure.
///
///
/// Type: PWSTR*
/// When this function returns, the array of strings containing the data extracted from the source PROPVARIANT.
///
///
/// Type: HRESULT
/// This function can return one of these values.
///
///
/// Return code
/// Description
///
/// -
/// S_OK
/// Returns S_OK if successful, or an error value otherwise.
///
/// -
/// TYPE_E_BUFFERTOOSMALL
/// The sourcePROPVARIANTcontained more than crgsz values. The buffer pointed to by prgsz.
///
/// -
/// E_INVALIDARG
/// ThePROPVARIANTwas not of the appropriate type.
///
///
///
///
///
/// This helper function is used in places where the calling application expects a PROPVARIANT to hold an vector of string values
/// with a fixed number of elements.
///
/// This function works for the following PROPVARIANT types:
///
/// -
/// VT_VECTOR | VT_LPWSTR
///
/// -
/// VT_VECTOR | VT_BSTR
///
/// -
/// VT_ARRAY | VT_BSTR
///
///
///
/// If the source PROPVARIANT has a supported type, this helper function extracts up to crgsz string values and places an allocated
/// copy of each into the buffer pointed to by prgsz. If the PROPVARIANT contains more elements than will fit into the prgsz
/// buffer, this function returns an error and sets pcElem to 0.
///
///
/// Since each string in pointed to by the output buffer has been newly allocated, the calling application is responsible for using
/// CoTaskMemFree to free each string in the output buffer when they are no longer needed.
///
///
/// If a BSTR in the source PROPVARIANT is NULL, it is converted to a newly allocated string containing "" in the output.
///
/// Examples
///
public static HRESULT PropVariantToStringVector([In] PROPVARIANT propvar, out string[] prgsz)
{
var ve = (VarEnum)((int)propvar.vt & 0x0FFF);
if ((!propvar.vt.HasFlag(VARTYPE.VT_VECTOR) || ve != VarEnum.VT_LPWSTR && ve != VarEnum.VT_BSTR) && (!propvar.vt.HasFlag(VARTYPE.VT_ARRAY) || ve != VarEnum.VT_BSTR))
throw new ArgumentException("Unsupported element type.", nameof(propvar));
HRESULT hr = PropVariantToStringVectorAlloc(propvar, out var ptr, out uint cnt);
if (hr.Failed)
{
prgsz = new string[0];
return hr;
}
prgsz = new string[(int)cnt];
var sptrs = ptr.ToArray((int)cnt);
for (int i = 0; i < cnt; i++)
{
prgsz[i] = Marshal.PtrToStringUni(sptrs[i]);
Marshal.FreeCoTaskMem(sptrs[i]);
}
ptr.Dispose();
return hr;
}
/// Extracts data from a structure into a newly allocated strings in a newly allocated vector.
/// Reference to the source structure.
///
/// When this function returns, contains a pointer to a vector of strings extracted from source structure.
///
///
/// When this function returns, contains the count of string elements extracted from source structure.
///
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
[DllImport(Lib.PropSys, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb776562")]
public static extern HRESULT PropVariantToStringVectorAlloc([In] PROPVARIANT propVar, out SafeCoTaskMemHandle pprgf, out uint pcElem);
///
/// Extracts the string property value of a structure. If no value exists, then the specified default value
/// is returned.
///
/// Reference to a source structure.
/// Pointer to a default Unicode string value, for use where no value currently exists. May be NULL.
/// Returns string value or the default.
[DllImport(Lib.PropSys, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.LPWStr)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb776563")]
public static extern string PropVariantToStringWithDefault([In] PROPVARIANT propvarIn, [In, MarshalAs(UnmanagedType.LPWStr)] string pszDefault);
///
/// Extracts a string from a PROPVARIANT structure and places it into a STRRET structure.
///
///
/// Type: REFPROPVARIANT
/// Reference to a source PROPVARIANT structure.
///
///
/// Type: STRRET*
///
/// Points to the STRRET structure. When this function returns, the structure has been initialized to contain a copy of the extracted string.
///
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
///
///
/// This helper function is used in applications that wish to convert a string value in a PROPVARIANT structure into a STRRET
/// structure. For instance, an application implementing IShellFolder::GetDisplayNameOf may find this function useful.
///
///
/// If the source PROPVARIANT has type VT_LPWSTR or VT_BSTR, this function extracts the string and places it into the STRRET
/// structure. Otherwise, it attempts to convert the value in the PROPVARIANT structure into a string. If a conversion is not
/// possible, PropVariantToString will return a failure code. See PropVariantChangeType for a list of possible conversions. Of note,
/// VT_EMPTY is successfully converted to "".
///
/// In addition to the conversions provided by PropVariantChangeType, the following special cases apply to PropVariantToString.
///
/// -
///
/// Vector-valued PROPVARIANTs are converted to strings by separating each element with using "; ". For example, PropVariantToString
/// converts a vector of 3 integers, {3, 1, 4}, to the string "3; 1; 4". The semicolon is independent of the current locale.
///
///
/// -
///
/// VT_BLOB, VT_STREAM, VT_STREAMED_OBJECT, and VT_UNKNOWN values are converted to strings using an unsupported encoding. It is not
/// possible to decode strings created in this way and the format may change in the future.
///
///
///
///
/// If the extraction is successful, the function will initialize uType member of the STRRET structure with STRRET_WSTR and set the
/// pOleStr member of that structure to point to an allocated copy of the string. The calling application is responsible for using
/// CoTaskMemFree or StrRetToStr to free this string when it is no longer needed.
///
/// Examples
///
/// The following example, to be included as part of a larger program, demonstrates how to use PropVariantToString to access a string
/// value in a PROPVARIANT.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/propvarutil/nf-propvarutil-propvarianttostrret PSSTDAPI PropVariantToStrRet(
// REFPROPVARIANT propvar, STRRET *pstrret );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "a1a33606-172d-4ee7-98c9-ffec8eed98bf")]
public static extern HRESULT PropVariantToStrRet([In] PROPVARIANT propvar, IntPtr pstrret);
/// Extracts a UInt16 property value of a structure.
/// Reference to the source structure.
/// When this function returns, contains the extracted property value if one exists; otherwise, 0.
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
[DllImport(Lib.PropSys, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb776565")]
public static extern HRESULT PropVariantToUInt16([In] PROPVARIANT propVar, [MarshalAs(UnmanagedType.U2)] out ushort puiRet);
///
/// Extracts data from a PROPVARIANT structure into an unsigned short vector.
///
///
/// Type: REFPROPVARIANT
/// Reference to a source PROPVARIANT structure.
///
///
/// Type: USHORT*
///
/// Points to a buffer containing crgn unsigned short values. When this function returns, the buffer has been initialized with
/// pcElem unsigned short elements extracted from the source PROPVARIANT.
///
///
///
/// Type: ULONG
/// Size of the buffer pointed to by prgn in elements.
///
///
/// Type: ULONG*
/// When this function returns, contains the count of unsigned short values extracted from the source PROPVARIANT structure.
///
///
/// Type: HRESULT
/// This function can return one of these values.
///
///
/// Return code
/// Description
///
/// -
/// S_OK
/// Returns S_OK if successful, or an error value otherwise.
///
/// -
/// TYPE_E_BUFFERTOOSMALL
/// The source PROPVARIANT contained more than crgn values. The buffer pointed to by prgn.
///
/// -
/// E_INVALIDARG
/// The PROPVARIANT was not of the appropriate type.
///
///
///
///
///
/// This helper function is used in places where the calling application expects a PROPVARIANT to hold an vector of unsigned
/// short values with a fixed number of elements.
///
///
/// If the source PROPVARIANT has type VT_VECTOR | VT_UI2 or VT_ARRAY | VT_UI2, this helper function
/// extracts up to crgn unsigned short values and places them into the buffer pointed to by prgn. If the PROPVARIANT
/// contains more elements than will fit into the prgn buffer, this function returns an error and sets pcElem to 0.
///
/// Examples
///
/// The following example, to be included as part of a larger program, demonstrates how to use PropVariantToUInt16Vector to access an
/// unsigned short vector value in a PROPVARIANT.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/propvarutil/nf-propvarutil-propvarianttouint16vector PSSTDAPI
// PropVariantToUInt16Vector( REFPROPVARIANT propvar, USHORT *prgn, ULONG crgn, ULONG *pcElem );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "34fe404c-cef6-47d9-9eaf-8ab151bd4726")]
public static extern HRESULT PropVariantToUInt16Vector([In] PROPVARIANT propvar, [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] ushort[] prgn, uint crgn, out uint pcElem);
/// Extracts data from a structure into a newly allocated UInt16 vector.
/// Reference to the source structure.
///
/// When this function returns, contains a pointer to a vector of UInt16 values extracted from the source structure.
///
///
/// When this function returns, contains the count of UInt16 elements extracted from source structure.
///
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
[DllImport(Lib.PropSys, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb776567")]
public static extern HRESULT PropVariantToUInt16VectorAlloc([In] PROPVARIANT propVar, out SafeCoTaskMemHandle pprgf, out uint pcElem);
///
///
/// Extracts an unsigned short value from a PROPVARIANT structure. If no value exists, then the specified default value is returned.
///
///
///
/// Type: REFPROPVARIANT
/// Reference to a source PROPVARIANT structure.
///
///
/// Type: USHORT
/// Specifies a default property value, for use where no value currently exists.
///
///
/// Type: unsigned short
/// Returns extracted unsigned short value, or default.
///
///
///
/// This helper function is used in places where the calling application expects a PROPVARIANT to hold a unsigned short value.
/// For instance, an application obtaining values from a property store can use this to safely extract the unsigned short
/// value for UInt16 properties.
///
///
/// If the source PROPVARIANT has type VT_UI2, this helper function extracts the unsigned short value. Otherwise, it
/// attempts to convert the value in the PROPVARIANT structure into a unsigned short. If a conversion is not possible,
/// PropVariantToUInt16 will return a failure code and set puiRet to 0. See PropVariantChangeType for a list of possible conversions.
/// Of note, VT_EMPTY is successfully converted to 0.
///
/// Examples
///
/// The following example, to be included as part of a larger program, demonstrates how to use PropVariantToUInt16 to access a
/// unsigned short value in a PROPVARIANT.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/propvarutil/nf-propvarutil-propvarianttouint16withdefault PSSTDAPI_(USHORT)
// PropVariantToUInt16WithDefault( REFPROPVARIANT propvarIn, USHORT uiDefault );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "4346cef2-5e43-47bf-9bfb-0ede923872fd")]
public static extern ushort PropVariantToUInt16WithDefault([In] PROPVARIANT propvarIn, ushort uiDefault);
/// Extracts a UInt32 property value of a structure.
/// Reference to the source structure.
/// When this function returns, contains the extracted property value if one exists; otherwise, 0.
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
[DllImport(Lib.PropSys, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb776569")]
public static extern HRESULT PropVariantToUInt32([In] PROPVARIANT propVar, [MarshalAs(UnmanagedType.U4)] out uint pulRet);
///
/// Extracts data from a PROPVARIANT structure into an ULONG vector.
///
///
/// Type: REFPROPVARIANT
/// Reference to a source PROPVARIANT structure.
///
///
/// Type: ULONG*
///
/// Points to a buffer containing crgn ULONG values. When this function returns, the buffer has been initialized with pcElem
/// ULONG elements extracted from the source PROPVARIANT.
///
///
///
/// Type: ULONG
/// Size of the buffer pointed to by prgn, in elements.
///
///
/// Type: ULONG*
/// When this function returns, contains the count of ULONG values extracted from the source PROPVARIANT structure.
///
///
/// Type: HRESULT
/// This function can return one of these values.
///
///
/// Return code
/// Description
///
/// -
/// S_OK
/// Returns S_OK if successful, or an error value otherwise.
///
/// -
/// TYPE_E_BUFFERTOOSMALL
/// The source PROPVARIANT contained more than crgn values. The buffer pointed to by prgn is too small.
///
/// -
/// E_INVALIDARG
/// The PROPVARIANT was not of the appropriate type.
///
///
///
///
///
/// This helper function is used in places where the calling application expects a PROPVARIANT to hold an vector of ULONG
/// values with a fixed number of elements.
///
///
/// If the source PROPVARIANT has type VT_VECTOR | VT_UI4 or VT_ARRAY | VT_UI4, this helper function
/// extracts up to crgn ULONG values and places them into the buffer pointed to by prgn. If the PROPVARIANT contains
/// more elements than will fit into the prgn buffer, this function returns an error and sets pcElem to 0.
///
/// Examples
///
/// The following example, to be included as part of a larger program, demonstrates how to use PropVariantToUInt32Vector to access a
/// ULONG vector value in a PROPVARIANT.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/propvarutil/nf-propvarutil-propvarianttouint32vector PSSTDAPI
// PropVariantToUInt32Vector( REFPROPVARIANT propvar, ULONG *prgn, ULONG crgn, ULONG *pcElem );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "721a2f67-dfd1-4d95-8290-4457b8954a02")]
public static extern HRESULT PropVariantToUInt32Vector([In] PROPVARIANT propvar, [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] uint[] prgn, uint crgn, out uint pcElem);
/// Extracts data from a structure into a newly allocated UInt32 vector.
/// Reference to the source structure.
///
/// When this function returns, contains a pointer to a vector of UInt32 values extracted from the source structure.
///
///
/// When this function returns, contains the count of UInt32 elements extracted from source structure.
///
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
[DllImport(Lib.PropSys, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb776571")]
public static extern HRESULT PropVariantToUInt32VectorAlloc([In] PROPVARIANT propVar, out SafeCoTaskMemHandle pprgf, out uint pcElem);
///
/// Extracts a ULONG value from a PROPVARIANT structure. If no value exists, then a specified default value is returned.
///
///
/// Type: REFPROPVARIANT
/// Reference to a source PROPVARIANT structure.
///
///
/// Type: ULONG
/// Specifies a default property value, for use where no value currently exists.
///
///
/// Type: ULONG
/// Returns extracted ULONG value, or default.
///
///
///
/// This helper function is used in places where the calling application expects a PROPVARIANT to hold a ULONG value and would
/// like to use a default value if it does not. For instance, an application obtaining values from a property store can use this to
/// safely extract the ULONG value for UInt32 properties.
///
///
/// If the source PROPVARIANT has type VT_UI4, this helper function extracts the ULONG value. Otherwise, it attempts to
/// convert the value in the PROPVARIANT structure into a ULONG. If the source PROPVARIANT has type
/// VT_EMPTY or a conversion is not possible, then PropVariantToUInt32WithDefault will return the default provided by
/// ulDefault. See PropVariantChangeType for a list of possible conversions.
///
/// Examples
///
/// The following example, to be included as part of a larger program, demonstrates how to use PropVariantToUInt32WithDefault to
/// access a ULONG value in a PROPVARIANT.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/propvarutil/nf-propvarutil-propvarianttouint32withdefault PSSTDAPI_(ULONG)
// PropVariantToUInt32WithDefault( REFPROPVARIANT propvarIn, ULONG ulDefault );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "8ace8c3f-fea2-4b20-9e0b-3abfbd569b54")]
public static extern uint PropVariantToUInt32WithDefault([In] PROPVARIANT propvarIn, uint ulDefault);
/// Extracts a UInt64 property value of a structure.
/// Reference to the source structure.
/// When this function returns, contains the extracted property value if one exists; otherwise, 0.
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
[DllImport(Lib.PropSys, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb776573")]
public static extern HRESULT PropVariantToUInt64([In] PROPVARIANT propVar, [MarshalAs(UnmanagedType.U8)] out ulong pullRet);
///
/// Extracts data from a PROPVARIANT structure into a ULONGLONG vector.
///
///
/// Type: REFPROPVARIANT
/// Reference to a source PROPVARIANT structure.
///
///
/// Type: ULONGLONG*
///
/// Points to a buffer containing crgn ULONGLONG values. When this function returns, the buffer has been initialized with
/// pcElem ULONGLONG elements extracted from the source PROPVARIANT.
///
///
///
/// Type: ULONG
/// Size of the buffer pointed to by prgn, in elements.
///
///
/// Type: ULONG*
/// When this function returns, contains the count of ULONGLONG values extracted from the source PROPVARIANT structure.
///
///
/// Type: HRESULT
/// This function can return one of these values.
///
///
/// Return code
/// Description
///
/// -
/// S_OK
/// Returns S_OK if successful, or an error value otherwise.
///
/// -
/// TYPE_E_BUFFERTOOSMALL
/// The source PROPVARIANT contained more than crgn values. The buffer pointed to by prgn.
///
/// -
/// E_INVALIDARG
/// The PROPVARIANT was not of the appropriate type.
///
///
///
///
///
/// This helper function is used in places where the calling application expects a PROPVARIANT to hold an vector of ULONGLONG
/// values with a fixed number of elements.
///
///
/// If the source PROPVARIANT has type VT_VECTOR | VT_UI8 or VT_ARRAY | VT_UI8, this helper function
/// extracts up to crgn ULONGLONG values and places them into the buffer pointed to by prgn. If the PROPVARIANT
/// contains more elements than will fit into the prgn buffer, this function returns an error and sets pcElem to 0.
///
/// Examples
///
/// The following example, to be included as part of a larger program, demonstrates how to use PropVariantToUInt64Vector to access a
/// ULONGLONG vector value in a PROPVARIANT.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/propvarutil/nf-propvarutil-propvarianttouint64vector PSSTDAPI
// PropVariantToUInt64Vector( REFPROPVARIANT propvar, ULONGLONG *prgn, ULONG crgn, ULONG *pcElem );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "596c7a35-6645-4f66-b924-b71278778776")]
public static extern HRESULT PropVariantToUInt64Vector([In] PROPVARIANT propvar, [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] ulong[] prgn, uint crgn, out uint pcElem);
/// Extracts data from a structure into a newly allocated UInt64 vector.
/// Reference to the source structure.
///
/// When this function returns, contains a pointer to a vector of UInt64 values extracted from the source structure.
///
///
/// When this function returns, contains the count of UInt64 elements extracted from source structure.
///
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
[DllImport(Lib.PropSys, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb776575")]
public static extern HRESULT PropVariantToUInt64VectorAlloc([In] PROPVARIANT propVar, out SafeCoTaskMemHandle pprgf, out uint pcElem);
///
///
/// Extracts ULONGLONG value from a PROPVARIANT structure. If no value exists, then the specified default value is returned.
///
///
///
/// Type: REFPROPVARIANT
/// Reference to a source PROPVARIANT structure.
///
///
/// Type: ULONGLONG
/// Specifies a default property value, for use where no value currently exists.
///
///
/// Type: ULONGLONG
/// Returns the extracted unsigned LONGLONG value, or a default.
///
///
///
/// This helper function is used in places where the calling application expects a PROPVARIANT to hold a ULONGLONG value and
/// would like to use a default value if it does not. For instance, an application obtaining values from a property store can use
/// this to safely extract the ULONGLONG value for UInt64 properties.
///
///
/// If the source PROPVARIANT has type VT_UI8, this helper function extracts the ULONGLONG value. Otherwise, it
/// attempts to convert the value in the PROPVARIANT structure into a ULONGLONG. If the source PROPVARIANT has
/// type VT_EMPTY or a conversion is not possible, then PropVariantToUInt64WithDefault will return the default provided by
/// ullDefault. See PropVariantChangeType for a list of possible conversions.
///
/// Examples
///
/// The following example, to be included as part of a larger program, demonstrates how to use PropVariantToUInt64WithDefault to
/// access a ULONGLONG value in a PROPVARIANT.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/propvarutil/nf-propvarutil-propvarianttouint64withdefault
// PSSTDAPI_(ULONGLONG) PropVariantToUInt64WithDefault( REFPROPVARIANT propvarIn, ULONGLONG ullDefault );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "8ca0e25e-6a3f-41ff-9a4a-7cca9a02d07c")]
public static extern ulong PropVariantToUInt64WithDefault([In] PROPVARIANT propvarIn, ulong ullDefault);
/// Converts the contents of a structure to a VARIANT structure.
/// Reference to the source structure.
/// Pointer to a VARIANT structure. When this function returns, the VARIANT contains the converted information.
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
[DllImport(Lib.PropSys, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb776577")]
public static extern HRESULT PropVariantToVariant([In] PROPVARIANT pPropVar, IntPtr pVar);
///
///
/// Extracts data from a PROPVARIANT structure into a Windows Runtime property value. Note that in some cases more than one
/// PROPVARIANT type maps to a single Windows Runtime property type.
///
///
///
/// Reference to a source PROPVARIANT structure.
///
///
/// A reference to the IID of the interface to retrieve through ppv, typically IID_IPropertyValue (defined in Windows.Foundation.h).
///
///
///
/// When this method returns successfully, contains the interface pointer requested in riid. This is typically an IPropertyValue
/// pointer. If the call fails, this value is NULL.
///
///
///
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
///
///
/// We recommend that you use the IID_PPV_ARGS macro, defined in Objbase.h, to package the riid and ppv parameters. This macro
/// provides the correct IID based on the interface pointed to by the value in ppv, which eliminates the possibility of a coding
/// error in riid that could lead to unexpected results.
///
///
// https://docs.microsoft.com/en-us/windows/desktop/api/propsys/nf-propsys-propvarianttowinrtpropertyvalue PSSTDAPI
// PropVariantToWinRTPropertyValue( REFPROPVARIANT propvar, REFIID riid, void **ppv );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propsys.h", MSDNShortId = "38DD3673-17FD-4F2A-BA58-A1A9983B92BF")]
public static extern HRESULT PropVariantToWinRTPropertyValue([In] PROPVARIANT propvar, in Guid riid, [MarshalAs(UnmanagedType.IUnknown)] out object ppv);
/// Deserializes a specified SERIALIZEDPROPERTYVALUE structure, creating a PROPVARIANT structure.
///
/// Type: const SERIALIZEDPROPERTYVALUE*
/// Pointer to a SERIALIZEDPROPERTYVALUE structure.
///
///
/// Type: ULONG
/// The size of the SERIALIZEDPROPERTYVALUE structure, in bytes.
///
///
/// Type: PROPVARIANT*
/// Pointer to the resulting PROPVARIANT structure.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
// HRESULT StgDeserializePropVariant( _In_ const SERIALIZEDPROPERTYVALUE *pprop, _In_ ULONG cbMax, _Out_ PROPVARIANT *ppropvar); https://msdn.microsoft.com/en-us/library/windows/desktop/bb776578(v=vs.85).aspx
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb776578")]
public static extern HRESULT StgDeserializePropVariant([In] IntPtr pprop, [In] uint cbMax, [In, Out] PROPVARIANT ppropvar);
/// Serializes a specified PROPVARIANT structure, creating a SERIALIZEDPROPERTYVALUE structure.
///
/// Type: const PROPVARIANT*
/// A constant pointer to the source PROPVARIANT structure.
///
///
/// Type: SERIALIZEDPROPERTYVALUE**
/// The address of a pointer to the SERIALIZEDPROPERTYVALUE structure.
///
///
/// Type: ULONG*
/// A pointer to the value representing the size of the SERIALIZEDPROPERTYVALUE structure.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
// HRESULT StgSerializePropVariant( _In_ const PROPVARIANT *ppropvar, _Out_ SERIALIZEDPROPERTYVALUE **ppProp, _Out_ ULONG *pcb); https://msdn.microsoft.com/en-us/library/windows/desktop/bb776579(v=vs.85).aspx
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb776579")]
public static extern HRESULT StgSerializePropVariant([In] PROPVARIANT ppropvar, out SafeCoTaskMemHandle ppProp, out uint pcb);
/// Compares two variant structures, based on default comparison rules.
///
/// Type: REFVARIANT
/// Reference to a first variant structure.
///
///
/// Type: REFVARIANT
/// Reference to a second variant structure.
///
///
/// Type: INT
///
/// -
/// Returns 1 if var1 is greater than var2
///
/// -
/// Returns 0 if var1 equals var2
///
/// -
/// Returns -1 if var1 is less than var2
///
///
///
///
///
/// Note This function does not support the comparison of different VARIANT types. If the types named in var1 and var2 are
/// different, the results are undefined and should be ignored. Calling applications should ensure that they are comparing two of the
/// same type before they call this function. The PropVariantChangeType function can be used to convert the two structures to the
/// same type.
///
/// By default, VT_NULL / VT_EMPTY / 0-element vectors are considered to be less than any other vartype.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-variantcompare PSSTDAPI_(int) VariantCompare(
// REFVARIANT var1, REFVARIANT var2 );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "45aed78c-1614-4aad-a930-c44615546d6f")]
public static extern int VariantCompare(in VARIANT var1, in VARIANT var2);
/// Extracts a single Boolean element from a variant structure.
///
/// Type: REFVARIANT
/// Reference to a source variant structure.
///
///
/// Type: ULONG
/// Specifies vector or array index; otherwise, value must be 0.
///
///
/// Type: BOOL*
/// Pointer to the extracted element value.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-variantgetbooleanelem PSSTDAPI
// VariantGetBooleanElem( REFVARIANT var, ULONG iElem, BOOL *pfVal );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "d21ad8cc-5919-4582-a593-64bd98a82a89")]
public static extern HRESULT VariantGetBooleanElem(in VARIANT var, uint iElem, [MarshalAs(UnmanagedType.Bool)] out bool pfVal);
/// Extracts one double element from a variant structure.
///
/// Type: REFVARIANT
/// Reference to a source variant structure.
///
///
/// Type: ULONG
/// Specifies vector or array index; otherwise, value must be 0.
///
///
/// Type: DOUBLE*
/// Pointer to the extracted element value.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-variantgetdoubleelem PSSTDAPI VariantGetDoubleElem(
// REFVARIANT var, ULONG iElem, DOUBLE *pnVal );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "cc6cb3a0-ba39-4088-8d72-082f6a4e39d3")]
public static extern HRESULT VariantGetDoubleElem(in VARIANT var, uint iElem, out double pnVal);
/// Retrieves the element count of a variant structure.
///
/// Type: REFVARIANT
/// Reference to a source variant structure.
///
///
/// Type: ULONG
/// Returns the element count for values of type VT_ARRAY; otherwise, returns 1.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-variantgetelementcount PSSTDAPI_(ULONG)
// VariantGetElementCount( REFVARIANT varIn );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "2bf96650-c0c4-4c99-9a04-d36d506b8f68")]
public static extern uint VariantGetElementCount(in VARIANT varIn);
/// Extracts a single Int16 element from a variant structure.
///
/// Type: REFVARIANT
/// Reference to a source variant structure.
///
///
/// Type: ULONG
/// Specifies vector or array index; otherwise, value must be 0.
///
///
/// Type: SHORT*
/// Pointer to the extracted element value.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-variantgetint16elem PSSTDAPI VariantGetInt16Elem(
// REFVARIANT var, ULONG iElem, SHORT *pnVal );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "fd572a65-c74c-490e-8cff-aa9ba54da5a1")]
public static extern HRESULT VariantGetInt16Elem(in VARIANT var, uint iElem, out short pnVal);
/// Extracts a single Int32 element from a variant structure.
///
/// Type: REFVARIANT
/// Reference to a source variant structure.
///
///
/// Type: ULONG
/// Specifies vector or array index; otherwise, value must be 0.
///
///
/// Type: LONG*
/// Pointer to the extracted element value.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-variantgetint32elem PSSTDAPI VariantGetInt32Elem(
// REFVARIANT var, ULONG iElem, LONG *pnVal );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "de67face-9284-4e0a-8ea7-d4b6e7c037fc")]
public static extern HRESULT VariantGetInt32Elem(in VARIANT var, uint iElem, out int pnVal);
/// Extracts a single Int64 element from a variant structure.
///
/// Type: REFVARIANT
/// Reference to a source variant structure.
///
///
/// Type: ULONG
/// Specifies vector or array index; otherwise, value must be 0.
///
///
/// Type: LONGLONG*
/// Pointer to the extracted element value.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-variantgetint64elem PSSTDAPI VariantGetInt64Elem(
// REFVARIANT var, ULONG iElem, LONGLONG *pnVal );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "285705d3-3b8e-40ad-abf2-1adc5adda3d8")]
public static extern HRESULT VariantGetInt64Elem(in VARIANT var, uint iElem, out long pnVal);
/// Extracts a single wide string element from a variant structure.
///
/// Type: REFVARIANT
/// Reference to a source variant structure.
///
///
/// Type: ULONG
/// Specifies a vector or array index; otherwise, value must be 0.
///
///
/// Type: PWSTR*
/// The address of a pointer to the extracted element value.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-variantgetstringelem PSSTDAPI VariantGetStringElem(
// REFVARIANT var, ULONG iElem, PWSTR *ppszVal );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "c4d1a37e-f7d1-4c0e-8d05-93a0153f2878")]
public static extern HRESULT VariantGetStringElem(in VARIANT var, uint iElem, out StrPtrUni ppszVal);
/// Extracts a single unsigned Int16 element from a variant structure.
///
/// Type: REFVARIANT
/// Reference to a source variant structure.
///
///
/// Type: ULONG
/// Specifies a vector or array index; otherwise, value must be 0.
///
///
/// Type: USHORT*
/// Pointer to the extracted element value.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-variantgetuint16elem PSSTDAPI VariantGetUInt16Elem(
// REFVARIANT var, ULONG iElem, USHORT *pnVal );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "6d2a8b0b-bcd2-4bad-a006-2443eabd7a16")]
public static extern HRESULT VariantGetUInt16Elem(in VARIANT var, uint iElem, out ushort pnVal);
/// Extracts a single unsigned Int32 element from a variant structure.
///
/// Type: REFVARIANT
/// Reference to a source variant structure.
///
///
/// Type: ULONG
/// Specifies vector or array index; otherwise, value must be 0.
///
///
/// Type: ULONG*
/// Pointer to the extracted element value.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-variantgetuint32elem PSSTDAPI VariantGetUInt32Elem(
// REFVARIANT var, ULONG iElem, ULONG *pnVal );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "b950d051-2500-4523-8307-5817274878f2")]
public static extern HRESULT VariantGetUInt32Elem(in VARIANT var, uint iElem, out uint pnVal);
/// Extracts a single unsigned Int64 element from a variant structure.
///
/// Type: REFVARIANT
/// Reference to a source variant structure.
///
///
/// Type: ULONG
/// Specifies vector or array index; otherwise, value must be 0.
///
///
/// Type: ULONGLONG*
/// Pointer to the extracted element value.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-variantgetuint64elem PSSTDAPI VariantGetUInt64Elem(
// REFVARIANT var, ULONG iElem, ULONGLONG *pnVal );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "7fd3c87b-5511-4dbc-b99e-65656a96303e")]
public static extern HRESULT VariantGetUInt64Elem(in VARIANT var, uint iElem, out ulong pnVal);
///
/// Extracts the value of a Boolean property from a VARIANT structure. If no value can be extracted, then a default value is assigned.
///
///
/// Type: REFVARIANT
/// Reference to a source VARIANT structure.
///
///
/// Type: BOOL*
/// When this function returns, contains the extracted value if one exists; otherwise, FALSE.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
///
///
/// This helper function is used when the calling application expects a VARIANT to hold a Boolean value. For instance, an application
/// that obtains values from a Shell folder can use this function to safely extract the value from one of the folder's Boolean properties.
///
/// If the source VARIANT is of type VT_BOOL, this function extracts the BOOL value.
///
/// If the source VARIANT is not of type VT_BOOL, this function attempts to convert the value in the VARIANT structure into a
/// BOOL. If a conversion is not possible, VariantToBoolean returns a failure code and sets pfRet to FALSE. See
/// PropVariantChangeType for a list of possible conversions. Of note, VT_EMPTY is successfully converted to FALSE.
///
/// Examples
///
/// The following example, to be included as part of a larger program, demonstrates how to use VariantToBoolean to access a
/// BOOL value in a VARIANT.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-varianttoboolean PSSTDAPI VariantToBoolean(
// REFVARIANT varIn, BOOL *pfRet );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "3ad12c41-e124-45f1-99f1-92790121ad93")]
public static extern HRESULT VariantToBoolean(in VARIANT varIn, [MarshalAs(UnmanagedType.Bool)] out bool pfRet);
/// Extracts an array of Boolean values from a VARIANT structure.
///
/// Type: REFVARIANT
/// Reference to a source VARIANT structure.
///
///
/// Type: BOOL*
///
/// Pointer to a buffer that contains crgn Boolean values. When this function returns, the buffer has been initialized with *pcElem
/// BOOL elements extracted from the source VARIANT structure.
///
///
///
/// Type: ULONG
/// The number of elements in the buffer pointed to by prgf.
///
///
/// Type: ULONG*
///
/// When this function returns, contains a pointer to the count of BOOL elements extracted from the source VARIANT structure.
///
///
///
/// Type: HRESULT
/// Returns S_OK if successful, or an error value otherwise, including the following:
///
///
/// Return code
/// Description
///
/// -
/// TYPE_E_BUFFERTOOSMALL
/// The source VARIANT contained more than crgn values.
///
/// -
/// E_INVALIDARG
/// The VARIANT was not of the appropriate type.
///
///
///
///
///
/// This helper function is used when the calling application expects a VARIANT to hold an array that consists of a fixed number of
/// Boolean values.
///
///
/// If the source VARIANT is of type VT_ARRAY | VT_BOOL, this function extracts up to crgn BOOL values and places them into
/// the buffer pointed to by prgf. If the VARIANT contains more elements than will fit into the prgf buffer, this function
/// returns an error and sets *pcElem to 0.
///
/// Examples
///
/// The following example, to be included as part of a larger program, demonstrates how to use VariantToBooleanArray to access an
/// array of BOOL values stored in a VARIANT structure.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-varianttobooleanarray PSSTDAPI
// VariantToBooleanArray( REFVARIANT var, BOOL *prgf, ULONG crgn, ULONG *pcElem );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "80a1e7d4-ec11-4b16-ba05-b97f3bbf02d0")]
public static extern HRESULT VariantToBooleanArray(in VARIANT var, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2, ArraySubType = UnmanagedType.Bool)] bool[] prgf, uint crgn, out uint pcElem);
/// Allocates an array of BOOL values then extracts data from a VARIANT structure into that array.
///
/// Type: REFVARIANT
/// Reference to a source VARIANT structure.
///
///
/// Type: BOOL**
/// When this function returns, contains a pointer to an array of BOOL values extracted from the source VARIANT structure.
///
///
/// Type: ULONG*
/// When this function returns, contains a pointer to the count of elements extracted from the source VARIANT structure.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
///
/// This helper function is used when the calling application expects a VARIANT to hold an array of BOOL values.
///
/// If the source VARIANT is of type VT_ARRAY | VT_BOOL, this function extracts an array of BOOL values into a newly allocated
/// array. The calling application is responsible for using CoTaskMemFree to release the array pointed to by pprgf when it is no
/// longer needed.
///
/// Examples
///
/// The following example, to be included as part of a larger program, demonstrates how to use VariantToBooleanArrayAlloc to access
/// an array of BOOL values stored in a VARIANT structure.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-varianttobooleanarrayalloc PSSTDAPI
// VariantToBooleanArrayAlloc( REFVARIANT var, BOOL **pprgf, ULONG *pcElem );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "6a623ee0-d99e-47db-82f9-9008c618a526")]
public static extern HRESULT VariantToBooleanArrayAlloc(in VARIANT var, out SafeCoTaskMemHandle pprgf, out uint pcElem);
/// Extracts a BOOL value from a VARIANT structure. If no value exists, then the specified default value is returned.
///
/// Type: REFVARIANT
/// Reference to a source VARIANT structure.
///
///
/// Type: BOOL
/// The default value for use where no extractable value exists.
///
///
/// Type: BOOL
/// Returns the extracted BOOL value; otherwise, the default value specified in fDefault.
///
///
///
/// This helper function is used when the calling application expects a VARIANT to hold a BOOL value and wants to use a
/// default value if it does not.
///
/// If the source VARIANT is of type VT_BOOL, this helper extracts the BOOL value.
///
/// If the source VARIANT is not of type VT_BOOL, the function attempts to convert the value in the VARIANT into a BOOL.
///
///
/// If the source VARIANT is of type VT_EMPTY or a conversion is not possible, then VariantToBooleanWithDefault returns the default
/// value provided by fDefault. See PropVariantChangeType for a list of possible conversions.
///
/// Examples
///
/// The following example, to be included as part of a larger program, demonstrates how to use VariantToBooleanWithDefault to access
/// a BOOL value stored in a VARIANT structure.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-varianttobooleanwithdefault PSSTDAPI_(BOOL)
// VariantToBooleanWithDefault( REFVARIANT varIn, BOOL fDefault );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "523c6e75-a51c-4ef7-928c-0d228ab0d337")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool VariantToBooleanWithDefault(in VARIANT varIn, [MarshalAs(UnmanagedType.Bool)] bool fDefault);
/// Extracts the contents of a buffer stored in a VARIANT structure of type VT_ARRRAY | VT_UI1.
///
/// Type: REFVARIANT
/// Reference to a source VARIANT structure.
///
///
/// Type: VOID*
///
/// Pointer to a buffer of length cb bytes. When this function returns, contains the first cb bytes of the extracted buffer value.
///
///
///
/// Type: UINT
/// The size of the pv buffer, in bytes. The buffer should be the same size as the data to be extracted, or smaller.
///
///
/// Type: HRESULT
/// Returns one of the following values:
///
///
/// Return code
/// Description
///
/// -
/// S_OK
/// Data successfully extracted.
///
/// -
/// E_INVALIDARG
/// The VARIANT was not of type VT_ARRRAY | VT_UI1.
///
/// -
/// E_FAIL
/// The VARIANT buffer value had fewer than cb bytes.
///
///
///
///
///
/// This function is used when the calling application expects a VARIANT to hold a buffer value. The calling application should check
/// that the value has the expected length before it calls this function.
///
///
/// If the source VARIANT has type VT_ARRAY | VT_UI1, this function extracts the first cb bytes from the structure and places them in
/// the buffer pointed to by pv.
///
/// If the stored value has fewer than cb bytes, then VariantToBuffer fails and the buffer is not modified.
/// If the value has more than cb bytes, then VariantToBuffer succeeds and truncates the value.
/// Examples
///
/// The following example, to be included as part of a larger program, demonstrates how to use VariantToBuffer to access a structure
/// that has been stored in a VARIANT.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-varianttobuffer PSSTDAPI VariantToBuffer( REFVARIANT
// varIn, void *pv, UINT cb );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "2d310156-c274-4aaf-aee2-ac311a952889")]
public static extern HRESULT VariantToBuffer(in VARIANT varIn, byte[] pv, uint cb);
/// Extracts a date and time value in Microsoft MS-DOS format from a VARIANT structure.
///
/// Type: REFVARIANT
/// Reference to a source VARIANT structure.
///
///
/// Type: WORD*
/// When this function returns, contains the extracted WORD that represents a MS-DOS date.
///
///
/// Type: WORD*
/// When this function returns, contains the extracted contains the extracted WORD that represents a MS-DOS time.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
///
/// This helper function is used when the calling application expects a VARIANT to hold a datetime value.
/// If the source VARIANT is of type VT_DATE, this function extracts the datetime value.
///
/// If the source VARIANT is not of type VT_DATE, the function attempts to convert the value in the VARIANT structure
/// into the right format. If a conversion is not possible, VariantToDosDateTime returns a failure code. See PropVariantChangeType
/// for a list of possible conversions.
///
/// See DosDateTimeToVariantTime for more information about the formats of pwDate, pwTime, and the source datetime value.
/// Examples
///
/// The following example, to be included as part of a larger program, demonstrates how to use VariantToDosDateTime to access a
/// datetime value in a VARIANT.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-varianttodosdatetime PSSTDAPI VariantToDosDateTime(
// REFVARIANT varIn, WORD *pwDate, WORD *pwTime );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "ebbba4d9-8e97-422d-b52f-67c417f295cc")]
public static extern HRESULT VariantToDosDateTime(in VARIANT varIn, out ushort pwDate, out ushort pwTime);
/// Extracts a DOUBLE value from a VARIANT structure. If no value can be extracted, then a default value is assigned.
///
/// Type: REFVARIANT
/// Reference to a source VARIANT structure.
///
///
/// Type: DOUBLE*
/// When this function returns, contains the extracted value if one exists; otherwise, 0.0.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
///
///
/// This helper function is used when the calling application expects a VARIANT to hold a DOUBLE value. For instance, an
/// application that obtains values from a Shell folder can use this function to safely extract the value from one of the folder's
/// properties whose value is stored as a DOUBLE.
///
/// If the source VARIANT is of type VT_R8, this function extracts the DOUBLE value.
///
/// If the source VARIANT is not of type VT_R8, the function attempts to convert the value stored in the VARIANT structure
/// into a DOUBLE. If a conversion is not possible, VariantToDouble returns a failure code and sets pdblRet to . See
/// PropVariantChangeType for a list of possible conversions. Of note, VT_EMPTY is successfully converted to 0.0.
///
/// Examples
///
/// The following example, to be included as part of a larger program, demonstrates how to use VariantToDouble to access a
/// DOUBLE value stored in a VARIANT structure.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-varianttodouble PSSTDAPI VariantToDouble( REFVARIANT
// varIn, DOUBLE *pdblRet );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "7bd756c6-f02a-4cf4-9458-b3304e2da2db")]
public static extern HRESULT VariantToDouble(in VARIANT varIn, out double pdblRet);
/// Extracts an array of DOUBLE values from a VARIANT structure.
///
/// Type: REFVARIANT
/// Reference to a source VARIANT structure.
///
///
/// Type: DOUBLE*
///
/// Pointer to a buffer that contains crgn DOUBLE values. When this function returns, the buffer has been initialized with
/// *pcElem DOUBLE elements extracted from the source VARIANT structure.
///
///
///
/// Type: ULONG
/// The number of elements in the buffer pointed to by prgn.
///
///
/// Type: ULONG*
/// When this function returns, contains the count of DOUBLE elements extracted from the source VARIANT structure.
///
///
/// Type: HRESULT
/// Returns S_OK if successful, or an error value otherwise, including the following:
///
///
/// Return code
/// Description
///
/// -
/// TYPE_E_BUFFERTOOSMALL
/// The source VARIANT contained more than crgn values.
///
/// -
/// E_INVALIDARG
/// The VARIANT was not of the appropriate type.
///
///
///
///
///
/// This helper function is used when the calling application expects a VARIANT to hold an array that consists of a fixed number of
/// DOUBLE values.
///
///
/// If the source VARIANT has type VT_ARRAY | VT_DOUBLE, this function extracts up to crgn DOUBLE values and places them into
/// the buffer pointed to by prgn.
///
///
/// If the VARIANT contains more elements than will fit into the prgn buffer, this function returns an error and sets *pcElem to 0.
///
/// Examples
///
/// The following example, to be included as part of a larger program, demonstrates how to use VariantToDoubleArray to access a
/// DOUBLE array stored in a VARIANT.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-varianttodoublearray PSSTDAPI VariantToDoubleArray(
// REFVARIANT var, DOUBLE *prgn, ULONG crgn, ULONG *pcElem );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "6830c2e2-d19a-45d5-af15-debfb08548bc")]
public static extern HRESULT VariantToDoubleArray(in VARIANT var, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] double[] prgn, uint crgn, out uint pcElem);
/// Allocates an array of DOUBLE values then extracts data from a VARIANT structure into that array.
///
/// Type: REFVARIANT
/// Reference to a source VARIANT structure.
///
///
/// Type: DOUBLE**
/// When this function returns, contains a pointer to an array of DOUBLE values extracted from the source VARIANT structure.
///
///
/// Type: ULONG*
/// When this function returns, contains a pointer to the count of elements extracted from the source VARIANT structure.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
///
/// This helper function is used when the calling application expects a VARIANT to hold an array of DOUBLE values.
///
/// If the source VARIANT is of type VT_ARRAY | VT_R8, this function extracts an array of DOUBLE values into a newly allocated
/// array. The calling application is responsible for using CoTaskMemFree to release the array pointed to by pprgn when it is no
/// longer needed.
///
/// Examples
///
/// The following example, to be included as part of a larger program, demonstrates how to use VariantToDoubleArrayAlloc to access a
/// DOUBLE array value in a VARIANT.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-varianttodoublearrayalloc PSSTDAPI
// VariantToDoubleArrayAlloc( REFVARIANT var, DOUBLE **pprgn, ULONG *pcElem );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "334d192e-7f63-47b4-88d4-9361e679cb15")]
public static extern HRESULT VariantToDoubleArrayAlloc(in VARIANT var, out SafeCoTaskMemHandle pprgn, out uint pcElem);
///
/// Extracts a DOUBLE value from a VARIANT structure. If no value exists, then the specified default value is returned.
///
///
/// Type: REFVARIANT
/// Reference to a source VARIANT structure.
///
///
/// Type: DOUBLE
/// The default value for use where no extractable value exists.
///
///
/// Type: DOUBLE
/// Returns the extracted double value; otherwise, the default value specified in dblDefault.
///
///
///
/// This helper function is used when the calling application expects a VARIANT to hold a DOUBLE value and wants to use a
/// default value if it does not.
///
/// If the source VARIANT is of type VT_R8, this helper extracts the DOUBLE value.
/// If the source VARIANT is not of type VT_R8, the function attempts to convert the value in the VARIANT into a DOUBLE.
///
/// If the source VARIANT is of type VT_EMPTY or a conversion is not possible, then VariantToDoubleWithDefault returns the default
/// value provided by dblDefault. See PropVariantChangeType for a list of possible conversions.
///
/// Examples
///
/// The following example, to be included as part of a larger program, demonstrates how to use VariantToDoubleWithDefault to access a
/// DOUBLE value stored in a VARIANT structure.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-varianttodoublewithdefault PSSTDAPI_(DOUBLE)
// VariantToDoubleWithDefault( REFVARIANT varIn, DOUBLE dblDefault );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "a3e32a30-363d-487e-bdd5-ac2616d6de14")]
public static extern double VariantToDoubleWithDefault(in VARIANT varIn, double dblDefault);
/// Extracts a FILETIME structure from a variant structure.
///
/// Type: REFVARIANT
/// Reference to a source variant structure.
///
///
/// Type: PSTIME_FLAGS
/// Specifies one of the following time flags:
/// PSTF_UTC (0)
/// Indicates coordinated universal time.
/// PSTF_LOCAL (1)
/// Indicates local time.
///
///
/// Type: FILETIME*
/// Pointer to the extracted FILETIME structure.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
/// stfOut flags override any property description flags.
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-varianttofiletime PSSTDAPI VariantToFileTime(
// REFVARIANT varIn, PSTIME_FLAGS stfOut, FILETIME *pftOut );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "e3094bd1-e641-43d8-8bc5-926c8d5a6ebe")]
public static extern HRESULT VariantToFileTime(in VARIANT varIn, PSTIME_FLAGS stfOut, out FILETIME pftOut);
/// Extracts a GUID property value of a variant structure.
///
/// Type: REFVARIANT
/// Reference to a source variant structure.
///
///
/// Type: GUID*
/// Pointer to the extracted property value.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-varianttoguid PSSTDAPI VariantToGUID( REFVARIANT
// varIn, GUID *pguid );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "1af84b55-da7e-430c-97fe-1c544a40c039")]
public static extern HRESULT VariantToGUID(in VARIANT varIn, out Guid pguid);
///
/// Extracts the Int16 property value of a variant structure. If no value can be extracted, then a default value is assigned
/// by this function.
///
///
/// Type: REFVARIANT
/// Reference to a source variant structure.
///
///
/// Type: SHORT*
/// Pointer to the extracted property value if one exists; otherwise, 0.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-varianttoint16 PSSTDAPI VariantToInt16( REFVARIANT
// varIn, SHORT *piRet );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "5a0d22c1-4295-405d-a503-2b9fdd6eaa81")]
public static extern HRESULT VariantToInt16(in VARIANT varIn, out short piRet);
/// Extracts data from a vector structure into an Int16 array.
///
/// Type: REFVARIANT
/// Reference to a source variant structure.
///
///
/// Type: SHORT*
/// Pointer to the Int16 data extracted from source variant structure.
///
///
/// Type: ULONG
/// Specifies Int16 array size.
///
///
/// Type: ULONG*
/// Pointer to the count of Int16 elements extracted from source variant structure.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-varianttoint16array PSSTDAPI VariantToInt16Array(
// REFVARIANT var, SHORT *prgn, ULONG crgn, ULONG *pcElem );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "dd00d986-acfa-445e-a0f6-0f52860b762b")]
public static extern HRESULT VariantToInt16Array(in VARIANT var, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] short[] prgn, uint crgn, out uint pcElem);
/// Extracts data from a vector structure into a newly-allocated Int16 array.
///
/// Type: REFVARIANT
/// Reference to a source variant structure.
///
///
/// Type: SHORT**
/// Pointer to the address of the Int16 data extracted from source variant structure.
///
///
/// Type: ULONG*
/// Pointer to the count of Int16 elements extracted from source variant structure.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-varianttoint16arrayalloc PSSTDAPI
// VariantToInt16ArrayAlloc( REFVARIANT var, SHORT **pprgn, ULONG *pcElem );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "616c9d03-f641-49e3-af95-80ebaea3e8aa")]
public static extern HRESULT VariantToInt16ArrayAlloc(in VARIANT var, out SafeCoTaskMemHandle pprgn, out uint pcElem);
///
/// Extracts an Int16 property value of a variant structure. If no value exists, then the specified default value is returned.
///
///
/// Type: REFVARIANT
/// Reference to a source variant structure.
///
///
/// Type: SHORT
/// Specifies default property value, for use where no value currently exists.
///
///
/// Type: SHORT
/// Returns the extracted Int16 value, or default.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-varianttoint16withdefault PSSTDAPI_(SHORT)
// VariantToInt16WithDefault( REFVARIANT varIn, SHORT iDefault );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "4d6d0b7d-ae20-456c-9ef4-97fa682ece8b")]
public static extern short VariantToInt16WithDefault(in VARIANT varIn, short iDefault);
///
/// Extracts an Int32 property value of a variant structure. If no value can be extracted, then a default value is assigned.
///
///
/// Type: REFVARIANT
/// Reference to a source variant structure.
///
///
/// Type: LONG*
/// Pointer to the extracted property value if one exists; otherwise, 0.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-varianttoint32 PSSTDAPI VariantToInt32( REFVARIANT
// varIn, LONG *plRet );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "6d2a4b8f-2ec5-4ffd-80b0-6615fdfb2379")]
public static extern HRESULT VariantToInt32(in VARIANT varIn, out int plRet);
/// Extracts data from a vector structure into an Int32 array.
///
/// Type: REFVARIANT
/// Reference to a source variant structure.
///
///
/// Type: LONG*
/// Pointer to the Int32 data extracted from source variant structure.
///
///
/// Type: ULONG
/// Specifies Int32 array size.
///
///
/// Type: ULONG*
/// Pointer to the count of Int32 elements extracted from source variant structure.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-varianttoint32array PSSTDAPI VariantToInt32Array(
// REFVARIANT var, LONG *prgn, ULONG crgn, ULONG *pcElem );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "9407e400-1621-4d96-b541-579aa3ac7a67")]
public static extern HRESULT VariantToInt32Array(in VARIANT var, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] int[] prgn, uint crgn, out uint pcElem);
/// Extracts data from a vector structure into a newly-allocated Int32 array.
///
/// Type: REFVARIANT
/// Reference to a source variant structure.
///
///
/// Type: LONG**
/// Pointer to the address of the Int32 data extracted from source variant structure.
///
///
/// Type: ULONG*
/// Pointer to the count of Int32 elements extracted from source variant structure.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-varianttoint32arrayalloc PSSTDAPI
// VariantToInt32ArrayAlloc( REFVARIANT var, LONG **pprgn, ULONG *pcElem );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "6010ee34-d7d2-4b8b-a49b-0f2aa88a3b54")]
public static extern HRESULT VariantToInt32ArrayAlloc(in VARIANT var, out SafeCoTaskMemHandle pprgn, out uint pcElem);
///
/// Extracts an Int32 property value of a variant structure. If no value exists, then the specified default value is returned.
///
///
/// Type: REFVARIANT
/// Reference to a source variant structure.
///
///
/// Type: LONG
/// Specifies default property value, for use where no value currently exists.
///
///
/// Type: LONG
/// Returns the extracted Int32 value, or default.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-varianttoint32withdefault PSSTDAPI_(LONG)
// VariantToInt32WithDefault( REFVARIANT varIn, LONG lDefault );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "fd2d5330-2b31-4dbb-b57b-4ca5579fa03f")]
public static extern int VariantToInt32WithDefault(in VARIANT varIn, int lDefault);
///
/// Extracts an Int64 property value of a variant structure. If no value can be extracted, then a default value is assigned.
///
///
/// Type: REFVARIANT
/// Reference to a source variant structure.
///
///
/// Type: LONGLONG*
/// Pointer to the extracted property value if one exists; otherwise, 0.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-varianttoint64 PSSTDAPI VariantToInt64( REFVARIANT
// varIn, LONGLONG *pllRet );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "5b8b4f93-dff1-40ef-9f99-c108a0b1bf70")]
public static extern HRESULT VariantToInt64(in VARIANT varIn, out long pllRet);
/// Extracts data from a vector structure into an Int64 array.
///
/// Type: REFVARIANT
/// Reference to a source variant structure.
///
///
/// Type: LONGLONG*
/// Pointer to the Int64 data extracted from source variant structure.
///
///
/// Type: ULONG
/// Specifies Int64 array size.
///
///
/// Type: ULONG*
/// Pointer to the count of Int64 elements extracted from source variant structure.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-varianttoint64array PSSTDAPI VariantToInt64Array(
// REFVARIANT var, LONGLONG *prgn, ULONG crgn, ULONG *pcElem );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "936e87e8-8102-4da2-b388-147fab6ec16f")]
public static extern HRESULT VariantToInt64Array(in VARIANT var, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] long[] prgn, uint crgn, out uint pcElem);
/// Extracts data from a vector structure into a newly-allocated Int64 array.
///
/// Type: REFVARIANT
/// Reference to a source variant structure.
///
///
/// Type: LONGLONG**
/// Pointer to the address of the Int64 data extracted from source variant structure.
///
///
/// Type: ULONG*
/// Pointer to the count of Int64 elements extracted from source variant structure.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-varianttoint64arrayalloc PSSTDAPI
// VariantToInt64ArrayAlloc( REFVARIANT var, LONGLONG **pprgn, ULONG *pcElem );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "15a583bd-fdef-4802-a18b-0a21b9be5448")]
public static extern HRESULT VariantToInt64ArrayAlloc(in VARIANT var, out SafeCoTaskMemHandle pprgn, out uint pcElem);
///
/// Extracts an Int64 property value of a variant structure. If no value exists, then the specified default value is returned.
///
///
/// Type: REFVARIANT
/// Reference to a source variant structure.
///
///
/// Type: LONGLONG
/// Specifies default property value, for use where no value currently exists.
///
///
/// Type: LONGLONG
/// Returns extracted Int64 value, or default.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-varianttoint64withdefault PSSTDAPI_(LONGLONG)
// VariantToInt64WithDefault( REFVARIANT varIn, LONGLONG llDefault );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "c4a5fc5c-19f9-4313-9d98-a486bfdfb359")]
public static extern int VariantToInt64WithDefault(in VARIANT varIn, int llDefault);
/// Copies the contents of a VARIANT structure to a structure.
/// Pointer to a source VARIANT structure.
///
/// Pointer to a structure. When this function returns, the contains the
/// converted information.
///
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
[DllImport(Lib.PropSys, ExactSpelling = true)]
[PInvokeData("Propvarutil.h", MSDNShortId = "bb776616")]
public static extern HRESULT VariantToPropVariant([In] IntPtr pVar, [In, Out] PROPVARIANT pPropVar);
///
/// Extracts the variant value of a variant structure to a string. If no value can be extracted, then a default value is assigned.
///
///
/// Type: REFVARIANT
/// Reference to a source variant structure.
///
///
/// Type: PWSTR
/// Pointer to the extracted property value if one exists; otherwise, empty.
///
///
/// Type: UINT
/// Specifies string length, in characters.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-varianttostring PSSTDAPI VariantToString( REFVARIANT
// varIn, PWSTR pszBuf, UINT cchBuf );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "4850f9b8-8f86-4428-bf3b-f3abdc6047c1")]
public static extern HRESULT VariantToString(in VARIANT varIn, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszBuf, uint cchBuf);
///
/// Extracts the variant value of a variant structure to a newly-allocated string. If no value can be extracted, then a default value
/// is assigned.
///
///
/// Type: REFVARIANT
/// Reference to a source variant structure.
///
///
/// Type: PWSTR
/// Pointer to the extracted property value if one exists; otherwise, empty.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-varianttostringalloc PSSTDAPI VariantToStringAlloc(
// REFVARIANT varIn, PWSTR *ppszBuf );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "9cd4433c-d8ad-43ef-bdb9-9c1b8d8bea01")]
public static extern HRESULT VariantToStringAlloc(in VARIANT varIn, [MarshalAs(UnmanagedType.LPWStr)] out string ppszBuf);
/// Extracts data from a vector structure into a String array.
///
/// Type: REFVARIANT
/// Reference to a source variant structure.
///
///
/// Type: PWSTR*
/// Pointer to the string data extracted from source variant structure.
///
///
/// Type: ULONG
/// Specifies string array size.
///
///
/// Type: ULONG*
/// Pointer to the count of string elements extracted from source variant structure.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-varianttostringarray PSSTDAPI VariantToStringArray(
// REFVARIANT var, PWSTR *prgsz, ULONG crgsz, ULONG *pcElem );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "d19b12ad-408c-4502-ad59-49386784bd69")]
public static extern HRESULT VariantToStringArray(in VARIANT var, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2, ArraySubType = UnmanagedType.LPWStr)] string[] prgsz, uint crgsz, out uint pcElem);
/// Extracts data from a vector structure into a newly-allocated String array.
///
/// Type: REFVARIANT
/// Reference to a source variant structure.
///
///
/// Type: PWSTR**
/// The address of a pointer to the string data extracted from source variant structure.
///
///
/// Type: ULONG*
/// Pointer to the count of string elements extracted from source variant structure.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-varianttostringarrayalloc PSSTDAPI
// VariantToStringArrayAlloc( REFVARIANT var, PWSTR **pprgsz, ULONG *pcElem );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "2725b824-b26c-4b33-bc18-a6f4c0ef74e6")]
public static extern HRESULT VariantToStringArrayAlloc(in VARIANT var, out SafeCoTaskMemHandle pprgsz, out uint pcElem);
///
/// Extracts the string property value of a variant structure. If no value exists, then the specified default value is returned.
///
///
/// Type: REFVARIANT
/// Reference to a source variant structure.
///
///
/// Type: LPCWSTR
/// Pointer to the default Unicode string property value, for use where no value currently exists.
///
///
/// Type: PCWSTR
/// Returns the extracted string value, or default.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-varianttostringwithdefault PSSTDAPI_(PCWSTR)
// VariantToStringWithDefault( REFVARIANT varIn, LPCWSTR pszDefault );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("propvarutil.h", MSDNShortId = "f8ca7844-057f-4e95-a4a9-f03f1d2ad492")]
public static extern string VariantToStringWithDefault(in VARIANT varIn, string pszDefault);
/// If the source variant is a VT_BSTR, extracts string and places it into a STRRET structure.
///
/// Type: REFVARIANT
/// Reference to a source variant structure.
///
///
/// Type: STRRET*
/// Pointer to the extracted string if one exists.
/// This is one of those cross-reference scenarios. STRRET is defined in the Shell32 assembly.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-varianttostrret
// PSSTDAPI VariantToStrRet( REFVARIANT varIn, STRRET *pstrret );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "NF:propvarutil.VariantToStrRet")]
public static extern HRESULT VariantToStrRet(in VARIANT varIn, IntPtr pstrret);
///
/// Extracts an unsigned Int16 property value of a variant structure. If no value can be extracted, then a default value is
/// assigned by this function.
///
///
/// Type: REFVARIANT
/// Reference to a source variant structure.
///
///
/// Type: USHORT*
/// Pointer to the extracted property value if one exists; otherwise, 0.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-varianttouint16 PSSTDAPI VariantToUInt16( REFVARIANT
// varIn, USHORT *puiRet );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "aa88be72-9ea5-4668-a0c5-1ca5320bda00")]
public static extern HRESULT VariantToUInt16(in VARIANT varIn, out ushort puiRet);
/// Extracts data from a vector structure into an unsigned Int16 array.
///
/// Type: REFVARIANT
/// Reference to a source variant structure.
///
///
/// Type: USHORT*
/// Pointer to the unsigned Int16 data extracted from source variant structure.
///
///
/// Type: ULONG
/// Specifies unsigned Int16 array size.
///
///
/// Type: ULONG*
/// Pointer to the count of unsigned Int16 elements extracted from source variant structure.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-varianttouint16array PSSTDAPI VariantToUInt16Array(
// REFVARIANT var, USHORT *prgn, ULONG crgn, ULONG *pcElem );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "8da12aa7-f54e-4a38-b9bb-0dd019f8823b")]
public static extern HRESULT VariantToUInt16Array(in VARIANT var, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] ushort[] prgn, uint crgn, out uint pcElem);
/// Extracts data from a vector structure into a newly-allocated unsigned Int16 array.
///
/// Type: REFVARIANT
/// Reference to a source variant structure.
///
///
/// Type: USHORT**
/// Pointer to the address of the unsigned Int16 data extracted from the source variant structure.
///
///
/// Type: ULONG*
/// Pointer to the count of unsigned Int16 elements extracted from the source variant structure.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-varianttouint16arrayalloc PSSTDAPI
// VariantToUInt16ArrayAlloc( REFVARIANT var, USHORT **pprgn, ULONG *pcElem );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "59e8d295-3be4-4e9a-a096-ead777d3aa8a")]
public static extern HRESULT VariantToUInt16ArrayAlloc(in VARIANT var, out SafeCoTaskMemHandle pprgn, out uint pcElem);
///
/// Extracts an unsigned Int16 property value of a variant structure. If no value exists, then the specified default value is returned.
///
///
/// Type: REFVARIANT
/// Reference to a source variant structure.
///
///
/// Type: USHORT
/// Specifies default property value, for use where no value currently exists.
///
///
/// Type: USHORT
/// Returns extracted unsigned Int16 value, or default.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-varianttouint16withdefault PSSTDAPI_(USHORT)
// VariantToUInt16WithDefault( REFVARIANT varIn, USHORT uiDefault );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "937d64c3-f5af-4230-b811-6d5883ecaf86")]
public static extern ushort VariantToUInt16WithDefault(in VARIANT varIn, ushort uiDefault);
///
/// Extracts unsigned Int32 property value of a variant structure. If no value can be extracted, then a default value is assigned.
///
///
/// Type: REFVARIANT
/// Reference to a source variant structure.
///
///
/// Type: ULONG*
/// Pointer to the extracted property value if one exists; otherwise, 0.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-varianttouint32 PSSTDAPI VariantToUInt32( REFVARIANT
// varIn, ULONG *pulRet );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "24421477-8930-4c8f-8fee-5d8367123c7e")]
public static extern HRESULT VariantToUInt32(in VARIANT varIn, out uint pulRet);
/// Extracts data from a vector structure into an unsigned Int32 array.
///
/// Type: REFVARIANT
/// Reference to a source variant structure.
///
///
/// Type: ULONG*
/// Pointer to the unsigned Int32 data extracted from source variant structure.
///
///
/// Type: ULONG
/// Specifies unsigned Int32 array size.
///
///
/// Type: ULONG*
/// Pointer to the count of unsigned Int32 elements extracted from source variant structure.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-varianttouint32array PSSTDAPI VariantToUInt32Array(
// REFVARIANT var, ULONG *prgn, ULONG crgn, ULONG *pcElem );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "506a02f8-6390-44a0-9f14-bfc8fb7ad180")]
public static extern HRESULT VariantToUInt32Array(in VARIANT var, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] uint[] prgn, uint crgn, out uint pcElem);
/// Extracts data from a vector structure into a newly-allocated unsigned Int32 array.
///
/// Type: REFVARIANT
/// Reference to a source variant structure.
///
///
/// Type: ULONG**
/// The address of a pointer to the unsigned Int32 data extracted from source variant structure.
///
///
/// Type: ULONG*
/// Pointer to the count of unsigned Int32 elements extracted from source variant structure.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-varianttouint32arrayalloc PSSTDAPI
// VariantToUInt32ArrayAlloc( REFVARIANT var, ULONG **pprgn, ULONG *pcElem );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "4d6cbfc8-fe1c-4bd0-8d29-32bce01d31f8")]
public static extern HRESULT VariantToUInt32ArrayAlloc(in VARIANT var, out SafeCoTaskMemHandle pprgn, out uint pcElem);
///
/// Extracts an unsigned Int32 property value of a variant structure. If no value currently exists, then the specified default
/// value is returned.
///
///
/// Type: REFVARIANT
/// Reference to a source variant structure.
///
///
/// Type: ULONG
/// Specifies default property value, for use where no value currently exists.
///
///
/// Type: ULONG
/// Returns extracted unsigned Int32 value, or default.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-varianttouint32withdefault PSSTDAPI_(ULONG)
// VariantToUInt32WithDefault( REFVARIANT varIn, ULONG ulDefault );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "02ec869b-154e-436a-a9b7-57eff4e958aa")]
public static extern uint VariantToUInt32WithDefault(in VARIANT varIn, uint ulDefault);
///
/// Extracts unsigned Int64 property value of a variant structure. If no value can be extracted, then a default value is assigned.
///
///
/// Type: REFVARIANT
/// Reference to a source variant structure.
///
///
/// Type: ULONGLONG*
/// Pointer to the extracted property value if one exists; otherwise, 0.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-varianttouint64 PSSTDAPI VariantToUInt64( REFVARIANT
// varIn, ULONGLONG *pullRet );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "1278f775-8439-4d05-acc9-b5207a3ccba7")]
public static extern HRESULT VariantToUInt64(in VARIANT varIn, out ulong pullRet);
/// Extracts data from a vector structure into an unsigned Int64 array.
///
/// Type: REFVARIANT
/// Reference to a source variant structure.
///
///
/// Type: ULONGLONG*
/// Pointer to the unsigned Int64 data extracted from source variant structure.
///
///
/// Type: ULONG
/// Specifies unsigned Int64 array size.
///
///
/// Type: ULONG*
/// Pointer to the count of unsigned Int64 elements extracted from source variant structure.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-varianttouint64array PSSTDAPI VariantToUInt64Array(
// REFVARIANT var, ULONGLONG *prgn, ULONG crgn, ULONG *pcElem );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "90b39ed2-a8a9-424c-bfd2-90517b9224fd")]
public static extern HRESULT VariantToUInt64Array(in VARIANT var, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] ulong[] prgn, uint crgn, out uint pcElem);
/// Extracts data from a vector structure into a newly-allocated unsigned Int64 array.
///
/// Type: REFVARIANT
/// Reference to a source variant structure.
///
///
/// Type: ULONGLONG**
/// The address of a pointer to the unsigned Int64 data extracted from source variant structure.
///
///
/// Type: ULONG*
/// Pointer to the count of unsigned Int64 elements extracted from source variant structure.
///
///
/// Type: HRESULT
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-varianttouint64arrayalloc PSSTDAPI
// VariantToUInt64ArrayAlloc( REFVARIANT var, ULONGLONG **pprgn, ULONG *pcElem );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "898edef6-a688-4a39-897c-70f29952db49")]
public static extern HRESULT VariantToUInt64ArrayAlloc(in VARIANT var, out SafeCoTaskMemHandle pprgn, out uint pcElem);
///
/// Extracts an unsigned Int64 property value of a variant structure. If no value currently exists, then the specified default
/// value is returned.
///
///
/// Type: REFVARIANT
/// Reference to a source variant structure.
///
///
/// Type: ULONGLONG
/// Specifies default property value, for use where no value currently exists.
///
///
/// Type: ULONGLONG
/// Returns the extracted unsigned Int64 value, or a default.
///
// https://docs.microsoft.com/en-us/windows/win32/api/propvarutil/nf-propvarutil-varianttouint64withdefault PSSTDAPI_(ULONGLONG)
// VariantToUInt64WithDefault( REFVARIANT varIn, ULONGLONG ullDefault );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propvarutil.h", MSDNShortId = "6ff75c81-519b-4539-9aa5-c6b39b3e2d94")]
public static extern ulong VariantToUInt64WithDefault(in VARIANT varIn, ulong ullDefault);
/// Copies the content from a Windows runtime property value to a PROPVARIANT structure.
///
/// A pointer to the IUnknown interface from which this function can access the contents of a Windows runtime property value by
/// retrieving and using the Windows::Foundation::IPropertyValue interface.
///
///
/// Pointer to a PROPVARIANT structure. When this function returns, the PROPVARIANT contains the converted info.
///
/// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
// https://docs.microsoft.com/en-us/windows/win32/api/propsys/nf-propsys-winrtpropertyvaluetopropvariant PSSTDAPI
// WinRTPropertyValueToPropVariant( IUnknown *punkPropertyValue, PROPVARIANT *ppropvar );
[DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)]
[PInvokeData("propsys.h", MSDNShortId = "3D6853B0-0A3F-4ACF-9C93-478688DAE9CF")]
public static extern HRESULT WinRTPropertyValueToPropVariant([MarshalAs(UnmanagedType.IUnknown)] object punkPropertyValue, PROPVARIANT ppropvar);
}
}