using VARTYPE = System.Runtime.InteropServices.VarEnum;
///...
[StructLayout(LayoutKind.Explicit, Pack = 8)]
public struct PROPVARIANT
{
/// <summary>Value type tag.</summary>
[FieldOffset(0)] public VARTYPE vt;
/// <summary>Reserved for future use.</summary>
[FieldOffset(2)] public ushort wReserved1;
/// <summary>Reserved for future use.</summary>
[FieldOffset(4)] public ushort wReserved2;
/// <summary>Reserved for future use.</summary>
[FieldOffset(6)] public ushort wReserved3;
/// <summary>The decimal value when VT_DECIMAL.</summary>
[FieldOffset(0)] internal decimal _decimal;
/// <summary>The raw data pointer.</summary>
[FieldOffset(8)] internal IntPtr _ptr;
/// <summary>The FILETIME when VT_FILETIME.</summary>
[FieldOffset(8)] internal System.Runtime.InteropServices.ComTypes.FILETIME _ft;
/// <summary>The BLOB when VT_BLOB</summary>
[FieldOffset(8)] internal Vanara.PInvoke.Ole32.BLOB _blob;
/// <summary>The value when a numeric value less than 8 bytes.</summary>
[FieldOffset(8)] internal ulong _ulong;
/// <summary>Initializes a new instance of the <see cref="PROPVARIANT"/> class as VT_EMPTY.</summary>
public PROPVARIANT()
{
}
public PROPVARIANT(string value)
{
ArgumentNullException.ThrowIfNull(value);
vt = VarEnum.VT_LPWSTR;
_ptr = Marshal.StringToCoTaskMemUni(value);
}
public VarEnum VarType { get => (VarEnum)vt; set => vt = (VARTYPE)value; }
}