• _variant_t 数据类型


    _variant_t类封闭了VARIANT数据类型,VARIANT是一个结构体类型,我们可以看一下它的定义

    typedef struct tagVARIANT  {
       VARTYPE vt;
       unsigned short wReserved1;
       unsigned short wReserved2;
       unsigned short wReserved3;
       union {
          Byte                    bVal;                 // VT_UI1.
          Short                   iVal;                 // VT_I2.
          long                    lVal;                 // VT_I4.
          float                   fltVal;               // VT_R4.
          double                  dblVal;               // VT_R8.
          VARIANT_BOOL            boolVal;              // VT_BOOL.
          SCODE                   scode;                // VT_ERROR.
          CY                      cyVal;                // VT_CY.
          DATE                    date;                 // VT_DATE.
          BSTR                    bstrVal;              // VT_BSTR.
          DECIMAL                 FAR* pdecVal          // VT_BYREF|VT_DECIMAL.
          IUnknown                FAR* punkVal;         // VT_UNKNOWN.
          IDispatch               FAR* pdispVal;        // VT_DISPATCH.
          SAFEARRAY               FAR* parray;          // VT_ARRAY|*.
          Byte                    FAR* pbVal;           // VT_BYREF|VT_UI1.
          short                   FAR* piVal;           // VT_BYREF|VT_I2.
          long                    FAR* plVal;           // VT_BYREF|VT_I4.
          float                   FAR* pfltVal;         // VT_BYREF|VT_R4.
          double                  FAR* pdblVal;         // VT_BYREF|VT_R8.
          VARIANT_BOOL            FAR* pboolVal;        // VT_BYREF|VT_BOOL.
          SCODE                   FAR* pscode;          // VT_BYREF|VT_ERROR.
          CY                      FAR* pcyVal;          // VT_BYREF|VT_CY.
          DATE                    FAR* pdate;           // VT_BYREF|VT_DATE.
          BSTR                    FAR* pbstrVal;        // VT_BYREF|VT_BSTR.
          IUnknown                FAR* FAR* ppunkVal;   // VT_BYREF|VT_UNKNOWN.
          IDispatch               FAR* FAR* ppdispVal;  // VT_BYREF|VT_DISPATCH.
          SAFEARRAY               FAR* FAR* pparray;    // VT_ARRAY|*.
          VARIANT                 FAR* pvarVal;         // VT_BYREF|VT_VARIANT.
          void                    FAR* byref;           // Generic ByRef.
          char                    cVal;                 // VT_I1.
          unsigned short          uiVal;                // VT_UI2.
          unsigned long           ulVal;                // VT_UI4.
          int                     intVal;               // VT_INT.
          unsigned int            uintVal;              // VT_UINT.
          char FAR *              pcVal;                // VT_BYREF|VT_I1.
          unsigned short FAR *    puiVal;               // VT_BYREF|VT_UI2.
          unsigned long FAR *     pulVal;               // VT_BYREF|VT_UI4.
          int FAR *               pintVal;              // VT_BYREF|VT_INT.
          unsigned int FAR *      puintVal;             //VT_BYREF|VT_UINT.
       };
    };
     vt用来存储存储变量的类型,联合体用来存储对用类型的值

    对_variant_t变量初始化调用的是_variant_t的构造函数,我们一般习惯于用一个int型的变量对数字类的变量进行初始化,这对_variant_t变量是不允许的,原因很简单,_variant_t的构造函数中没用用整型对其初始化的构造函数,可先将整型转化成long对其进行初始化,赋值操作与构造函数类似.


    文章出处:http://www.diybl.com/course/3_program/c++/cppsl/2008515/116920.html

  • 相关阅读:
    开源的Ajax.Net类库
    开放的即时通信协议Jabber
    代码生成工具之MyGeneration
    清华梦的粉碎—写给清华大学的退学申请(牛人 王垠 )
    [.NET网格计算框架] Alchemi
    .net安全类库
    使用Facility:EnterpriseLibrary整合进Castle
    castle project 发布新版本
    10招步骤保护IIS服务器安全
    应用IBatisNet+Castle进行项目的开发
  • 原文地址:https://www.cnblogs.com/wubiyu/p/1346344.html
Copyright © 2020-2023  润新知