internal static extern HRESULT PropVariantGetStringElem(
     [In] ref PropVariant propVar,
     [In] uint iElem,
     [Out][MarshalAs(UnmanagedType.LPWStr)] out string ppszVal);
 internal static extern HRESULT PropVariantGetFileTimeElem(
     [In] PropVariant propVar,
     [In] uint iElem,
     [Out][MarshalAs(UnmanagedType.Struct)] out FILETIME pftVal);
 internal static extern HRESULT PropVariantGetInt32Elem(
     [In] PropVariant propVar,
     [In] uint iElem,
     [Out] out Int32 pnVal);
 internal static extern HRESULT InitPropVariantFromInt16Vector(
     [In] Int16[] prgn,
     uint cElems,
     [Out] out PropVariant ppropvar);
 internal static extern HRESULT InitPropVariantFromResource(
     [In] IntPtr hinst,
     uint id,
     [Out] out PropVariant ppropvar);
 internal static extern HRESULT InitPropVariantFromBuffer(
     [In] byte[] pv,
     uint cb,
     [Out] out PropVariant ppropvar);
 internal static extern HRESULT InitPropVariantFromFileTime(
     [In] ref FILETIME pftIn,
     [Out] out PropVariant ppropvar);
 internal static extern HRESULT PropVariantChangeType(
     [Out] out PropVariant ppropvarDest,
     [In] ref PropVariant propvarSrc,
     [In] int flags,
     [In] ushort vt);
 internal static extern HRESULT PropVariantClear([In] ref PropVariant pvar);
 internal static extern HRESULT FreePropVariantArray(uint cVariants, [In][Out] ref PropVariant rgvars);
 internal static extern HRESULT InitPropVariantVectorFromPropVariant(
     [In] ref PropVariant propvarSingle,
     [Out] out PropVariant[] propvarVector);
 internal static extern HRESULT InitPropVariantFromStringVector(
     [In] string[] prgsz,
     uint cElems,
     [Out] out PropVariant ppropvar);
 internal static extern HRESULT InitPropVariantFromStringAsVector(
     [In] string psz,
     [Out] out PropVariant ppropvar);
 internal static extern void ClearPropVariantArray([In] ref PropVariant rgPropVar, uint vVars);
 internal static extern HRESULT PropVariantGetUInt64Elem(
     [In] PropVariant propVar,
     [In] uint iElem,
     [Out] out UInt64 pnVal);
 internal static extern HRESULT PropVariantCopy([Out] out PropVariant pDst, [In] ref PropVariant pSrc);
 internal static extern HRESULT InitPropVariantFromBooleanVector(
     [In] bool[] prgf,
     uint cElems,
     [Out] out PropVariant ppropvar);
 internal static extern HRESULT PropVariantGetBooleanElem(
     [In] PropVariant propVar,
     [In] uint iElem,
     [Out][MarshalAs(UnmanagedType.Bool)] out bool pfVal);
 internal static extern HRESULT InitPropVariantFromDoubleVector(
     [In] double[] prgn,
     uint cElems,
     [Out] out PropVariant ppropvar);
 internal static extern HRESULT PropVariantGetDoubleElem(
     [In] PropVariant propVar,
     [In] uint iElem,
     [Out] out double pnVal);
 internal static extern HRESULT InitPropVariantFromFileTimeVector(
     [In] FILETIME[] prgft,
     uint cElems,
     [Out] out PropVariant ppropvar);
 internal static extern int PropVariantGetElementCount([In] PropVariant propVar);
Example #23
0
        /// <summary>
        ///     指定した<paramref name="value" />から<see cref="PropVariant" />を作成します。
        ///     Create a new instance of the <see cref="PropVariant" /> struct
        ///     to the specified <see cref="object" />.
        /// </summary>
        /// <param name="value">オブジェクト。</param>
        /// <returns>作成した<see cref="PropVariant" />。</returns>
        public static PropVariant FromObject(object value)
        {
            if (value == null)
            {
                var result = new PropVariant();
                result.varType = (ushort)VarEnum.VT_EMPTY;
                return(result);
            }
            else
            {
                #region Create Value

                if (value is string)
                {
                    return(FromString((string)value));
                }
                else if (value is string[])
                {
                    return(FromStringArray((string[])value));
                }
                else if (value is sbyte)
                {
                    return(FromInt8((sbyte)value));
                }
                else if (value is byte)
                {
                    return(FromUInt8((byte)value));
                }
                else if (value is Int16)
                {
                    return(FromInt16((Int16)value));
                }
                else if (value is UInt16)
                {
                    return(FromUInt16((UInt16)value));
                }
                else if (value is Int32)
                {
                    return(FromInt32((Int32)value));
                }
                else if (value is UInt32)
                {
                    return(FromUInt32((UInt32)value));
                }
                else if (value is Int64)
                {
                    return(FromInt64((Int64)value));
                }
                else if (value is UInt64)
                {
                    return(FromUInt64((UInt64)value));
                }
                else if (value is float)
                {
                    return(FromSingle((float)value));
                }
                else if (value is double)
                {
                    return(FromDouble((double)value));
                }
                else if (value is bool)
                {
                    return(FromBoolean((bool)value));
                }
                else if (value is Guid)
                {
                    return(FromGuid((Guid)value));
                }

                #endregion
            }

            throw new InvalidOperationException();
        }
 internal static extern HRESULT InitPropVariantFromPropVariantVectorElem(
     [In] ref PropVariant propvarIn,
     uint iElem,
     [Out] out PropVariant ppropvar);