News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Does Anyone Know Where the VARIANT Type Constants Are Defined ???

Started by Zen, August 23, 2016, 07:13:00 AM

Previous topic - Next topic

Zen

NEVERMIND. They're in Windows.inc (weird, that's the first place I looked).

VARIANT Type Constants, MSDN
...aka,...VARENUM Enumeration Constants are used in the discriminant field, vt, of the VARIANT type.

By the way,...the best discussion about actually using VARIANTs that I have found is here: VARIANT Structure, Siekmanski

I'm trying to create a SAFEARRAY of VARIANTs,...and, I'm completely discombobulated. Anybody that has any tips,...please don't hesitate to elucidate. Otherwise, I'm gonna have to outsource my project to extraterrestrials (again). The best way appears to be, using: Array Manipulation Functions, MSDN

LiaoMi

You can see here comutil.h ?!

//////////////////////////////////////////////////////////////////////////////
//
// Wrapper class for VARIANT
//
//////////////////////////////////////////////////////////////////////////////

/*
* VARENUM usage key,
*
* * [V] - may appear in a VARIANT
* * [T] - may appear in a TYPEDESC
* * [P] - may appear in an OLE property set
* * [S] - may appear in a Safe Array
* * [C] - supported by class _variant_t
*
*
*  VT_EMPTY            [V]   [P]        nothing
*  VT_NULL             [V]   [P]        SQL style Null
*  VT_I2               [V][T][P][S][C]  2 byte signed int
*  VT_I4               [V][T][P][S][C]  4 byte signed int
*  VT_R4               [V][T][P][S][C]  4 byte real
*  VT_R8               [V][T][P][S][C]  8 byte real
*  VT_CY               [V][T][P][S][C]  currency
*  VT_DATE             [V][T][P][S][C]  date
*  VT_BSTR             [V][T][P][S][C]  OLE Automation string
*  VT_DISPATCH         [V][T][P][S][C]  IDispatch *
*  VT_ERROR            [V][T]   [S][C]  SCODE
*  VT_BOOL             [V][T][P][S][C]  True=-1, False=0
*  VT_VARIANT          [V][T][P][S]     VARIANT *
*  VT_UNKNOWN          [V][T]   [S][C]  IUnknown *
*  VT_DECIMAL          [V][T]   [S][C]  16 byte fixed point
*  VT_I1                  [T]           signed char
*  VT_UI1              [V][T][P][S][C]  unsigned char
*  VT_UI2                 [T][P]        unsigned short
*  VT_UI4                 [T][P]        unsigned short
*  VT_I8                  [T][P]        signed 64-bit int
*  VT_UI8                 [T][P]        unsigned 64-bit int
*  VT_INT                 [T]           signed machine int
*  VT_UINT                [T]           unsigned machine int
*  VT_VOID                [T]           C style void
*  VT_HRESULT             [T]           Standard return type
*  VT_PTR                 [T]           pointer type
*  VT_SAFEARRAY           [T]          (use VT_ARRAY in VARIANT)
*  VT_CARRAY              [T]           C style array
*  VT_USERDEFINED         [T]           user defined type
*  VT_LPSTR               [T][P]        null terminated string
*  VT_LPWSTR              [T][P]        wide null terminated string
*  VT_FILETIME               [P]        FILETIME
*  VT_BLOB                   [P]        Length prefixed bytes
*  VT_STREAM                 [P]        Name of the stream follows
*  VT_STORAGE                [P]        Name of the storage follows
*  VT_STREAMED_OBJECT        [P]        Stream contains an object
*  VT_STORED_OBJECT          [P]        Storage contains an object
*  VT_BLOB_OBJECT            [P]        Blob contains an object
*  VT_CF                     [P]        Clipboard format
*  VT_CLSID                  [P]        A Class ID
*  VT_VECTOR                 [P]        simple counted array
*  VT_ARRAY            [V]              SAFEARRAY*
*  VT_BYREF            [V]              void* for local use
*/

class _variant_t : public ::tagVARIANT {
public:
    // Constructors
    //
    _variant_t() throw();

    _variant_t(const VARIANT& varSrc) ;
    _variant_t(const VARIANT* pSrc) ;
    _variant_t(const _variant_t& varSrc) ;

    _variant_t(VARIANT& varSrc, bool fCopy) ;          // Attach VARIANT if !fCopy

    _variant_t(short sSrc, VARTYPE vtSrc = VT_I2) ;    // Creates a VT_I2, or a VT_BOOL
    _variant_t(long lSrc, VARTYPE vtSrc = VT_I4) ;     // Creates a VT_I4, a VT_ERROR, or a VT_BOOL
    _variant_t(float fltSrc) throw();                                   // Creates a VT_R4
    _variant_t(double dblSrc, VARTYPE vtSrc = VT_R8) ; // Creates a VT_R8, or a VT_DATE
    _variant_t(const CY& cySrc) throw();                                // Creates a VT_CY
    _variant_t(const _bstr_t& bstrSrc) ;               // Creates a VT_BSTR
    _variant_t(const wchar_t *pSrc) ;                  // Creates a VT_BSTR
    _variant_t(const char* pSrc) ;                     // Creates a VT_BSTR
    _variant_t(IDispatch* pSrc, bool fAddRef = true) throw();           // Creates a VT_DISPATCH
    _variant_t(bool boolSrc) throw();                                   // Creates a VT_BOOL
    _variant_t(IUnknown* pSrc, bool fAddRef = true) throw();            // Creates a VT_UNKNOWN
    _variant_t(const DECIMAL& decSrc) throw();                          // Creates a VT_DECIMAL
    _variant_t(BYTE bSrc) throw();                                      // Creates a VT_UI1

    _variant_t(char cSrc) throw();                                      // Creates a VT_I1
    _variant_t(unsigned short usSrc) throw();                           // Creates a VT_UI2
    _variant_t(unsigned long ulSrc) throw();                            // Creates a VT_UI4
    _variant_t(int iSrc) throw();                                       // Creates a VT_INT
    _variant_t(unsigned int uiSrc) throw();                             // Creates a VT_UINT
#if (_WIN32_WINNT >= 0x0501)
    _variant_t(__int64 i8Src) throw();                                  // Creates a VT_I8
    _variant_t(unsigned __int64 ui8Src) throw();                        // Creates a VT_UI8
#endif

    // Destructor
    //
    ~_variant_t() throw() ;

    // Extractors
    //
    operator short() const ;                           // Extracts a short from a VT_I2
    operator long() const ;                            // Extracts a long from a VT_I4
    operator float() const ;                           // Extracts a float from a VT_R4
    operator double() const ;                          // Extracts a double from a VT_R8
    operator CY() const ;                              // Extracts a CY from a VT_CY
    operator _bstr_t() const ;                         // Extracts a _bstr_t from a VT_BSTR
    operator IDispatch*() const ;                      // Extracts a IDispatch* from a VT_DISPATCH
    operator bool() const ;                            // Extracts a bool from a VT_BOOL
    operator IUnknown*() const ;                       // Extracts a IUnknown* from a VT_UNKNOWN
    operator DECIMAL() const ;                         // Extracts a DECIMAL from a VT_DECIMAL
    operator BYTE() const ;                            // Extracts a BTYE (unsigned char) from a VT_UI1
    operator VARIANT() const throw();

    operator char() const ;                            // Extracts a char from a VT_I1
    operator unsigned short() const ;                  // Extracts a unsigned short from a VT_UI2
    operator unsigned long() const ;                   // Extracts a unsigned long from a VT_UI4
    operator int() const ;                             // Extracts a int from a VT_INT
    operator unsigned int() const ;                    // Extracts a unsigned int from a VT_UINT
#if (_WIN32_WINNT >= 0x0501)
    operator __int64() const ;                         // Extracts a __int64 from a VT_I8
    operator unsigned __int64() const ;                // Extracts a unsigned __int64 from a VT_UI8
#endif

    // Assignment operations
    //
    _variant_t& operator=(const VARIANT& varSrc) ;
    _variant_t& operator=(const VARIANT* pSrc) ;
    _variant_t& operator=(const _variant_t& varSrc) ;

    _variant_t& operator=(short sSrc) ;                // Assign a VT_I2, or a VT_BOOL
    _variant_t& operator=(long lSrc) ;                 // Assign a VT_I4, a VT_ERROR or a VT_BOOL
    _variant_t& operator=(float fltSrc) ;              // Assign a VT_R4
    _variant_t& operator=(double dblSrc) ;             // Assign a VT_R8, or a VT_DATE
    _variant_t& operator=(const CY& cySrc) ;           // Assign a VT_CY
    _variant_t& operator=(const _bstr_t& bstrSrc) ;    // Assign a VT_BSTR
    _variant_t& operator=(const wchar_t* pSrc) ;       // Assign a VT_BSTR
    _variant_t& operator=(const char* pSrc) ;          // Assign a VT_BSTR
    _variant_t& operator=(IDispatch* pSrc) ;           // Assign a VT_DISPATCH
    _variant_t& operator=(bool boolSrc) ;              // Assign a VT_BOOL
    _variant_t& operator=(IUnknown* pSrc) ;            // Assign a VT_UNKNOWN
    _variant_t& operator=(const DECIMAL& decSrc) ;     // Assign a VT_DECIMAL
    _variant_t& operator=(BYTE bSrc) ;                 // Assign a VT_UI1

    _variant_t& operator=(char cSrc) ;                 // Assign a VT_I1
    _variant_t& operator=(unsigned short usSrc) ;      // Assign a VT_UI2
    _variant_t& operator=(unsigned long ulSrc) ;       // Assign a VT_UI4
    _variant_t& operator=(int iSrc) ;                  // Assign a VT_INT
    _variant_t& operator=(unsigned int uiSrc) ;        // Assign a VT_UINT
#if (_WIN32_WINNT >= 0x0501)
    _variant_t& operator=(__int64 i8Src) ;             // Assign a VT_I8
    _variant_t& operator=(unsigned __int64 ui8Src) ;   // Assign a VT_UI8
#endif

    // Comparison operations
    //
    bool operator==(const VARIANT& varSrc) const throw();
    bool operator==(const VARIANT* pSrc) const throw();

    bool operator!=(const VARIANT& varSrc) const throw();
    bool operator!=(const VARIANT* pSrc) const throw();

    // Low-level operations
    //
    void Clear() ;

    void Attach(VARIANT& varSrc) ;
    VARIANT Detach() throw();

    VARIANT& GetVARIANT() throw();
    VARIANT* GetAddress() ;

    void ChangeType(VARTYPE vartype, const _variant_t* pSrc = NULL) ;

    void SetString(const char* pSrc) ; // used to set ANSI string
};

Yuri

Quote from: Zen on August 23, 2016, 07:13:00 AM
The best way appears to be, using: Array Manipulation Functions, MSDN
It's probably the safest because those functions also know how memory should be allocated and freed for such an array, and you probably don't (neither do I).

LiaoMi

MS VS 2013 - WTypes.h

/*
enum VARENUM
    { VT_EMPTY = 0,
VT_NULL = 1,
VT_I2 = 2,
VT_I4 = 3,
VT_R4 = 4,
VT_R8 = 5,
VT_CY = 6,
VT_DATE = 7,
VT_BSTR = 8,
VT_DISPATCH = 9,
VT_ERROR = 10,
VT_BOOL = 11,
VT_VARIANT = 12,
VT_UNKNOWN = 13,
VT_DECIMAL = 14,
VT_I1 = 16,
VT_UI1 = 17,
VT_UI2 = 18,
VT_UI4 = 19,
VT_I8 = 20,
VT_UI8 = 21,
VT_INT = 22,
VT_UINT = 23,
VT_VOID = 24,
VT_HRESULT = 25,
VT_PTR = 26,
VT_SAFEARRAY = 27,
VT_CARRAY = 28,
VT_USERDEFINED = 29,
VT_LPSTR = 30,
VT_LPWSTR = 31,
VT_RECORD = 36,
VT_INT_PTR = 37,
VT_UINT_PTR = 38,
VT_FILETIME = 64,
VT_BLOB = 65,
VT_STREAM = 66,
VT_STORAGE = 67,
VT_STREAMED_OBJECT = 68,
VT_STORED_OBJECT = 69,
VT_BLOB_OBJECT = 70,
VT_CF = 71,
VT_CLSID = 72,
VT_VERSIONED_STREAM = 73,
VT_BSTR_BLOB = 0xfff,
VT_VECTOR = 0x1000,
VT_ARRAY = 0x2000,
VT_BYREF = 0x4000,
VT_RESERVED = 0x8000,
VT_ILLEGAL = 0xffff,
VT_ILLEGALMASKED = 0xfff,
VT_TYPEMASK = 0xfff
    } ;
typedef ULONG PROPID;

Zen