list of VARIANT
-
I want do built a list of VARIANT #include typedef std::list VARIANTLIST; VARIANTLIST varList; and I add a VARIANT into list varList; VARIANT pp; pp.vt=VT_I2; pp.iVal=1; varList.push_back(pp); then length of vatList is increased 1, but the comment is not right. What is the matter? Can you help me, Thanks.
-
I want do built a list of VARIANT #include typedef std::list VARIANTLIST; VARIANTLIST varList; and I add a VARIANT into list varList; VARIANT pp; pp.vt=VT_I2; pp.iVal=1; varList.push_back(pp); then length of vatList is increased 1, but the comment is not right. What is the matter? Can you help me, Thanks.
What do you mean with "then length of vatList is increased 1, but the comment is not right"? Daniel ;) --------------------------- Never change a running system!
-
I want do built a list of VARIANT #include typedef std::list VARIANTLIST; VARIANTLIST varList; and I add a VARIANT into list varList; VARIANT pp; pp.vt=VT_I2; pp.iVal=1; varList.push_back(pp); then length of vatList is increased 1, but the comment is not right. What is the matter? Can you help me, Thanks.
-
What do you mean with "then length of vatList is increased 1, but the comment is not right"? Daniel ;) --------------------------- Never change a running system!
-
Sorry, I spell a word wrong. I means then sizes of varList si increased 1, and now varList.size() return 1. but the element VARIANT whose vt is not VT_I2.
Sorry, but I think I don't understand :omg: :-O !!! I have tested your code:
// variant.cpp : Definiert den Einsprungpunkt für die Konsolenanwendung.
//#include "stdafx.h"
#include <atlbase.h>
#include <list>typedef std::list<VARIANT> VARIANTLIST;
VARIANTLIST varList;int main(int argc, char* argv[])
{
for (int n = 0; n < 100; n++)
{
VARIANT var;
var.vt = VT_I2;
var.iVal = 1;varList.push\_back(var); } printf("size = %d \\n", (int) varList.size()); return 0;
}
There is all right with the code! I have a
std::list
ofVARIANT
and add 100 members ofVARIANT
to the list! The varList.size() function returns the count of elements in the list and so it returns 100 and that's right! TheVT_I2
says that theVARIANT
holdsshort
members. I2 says that the member is an integer who need 2 byte of space in the memory (sizeof(short) = 2
). Take a look in the MSDN:typedef struct tagVARIANT {
VARTYPE vt;
unsigned short wReserved1;
unsigned short wReserved2;
unsigned short wReserved3;
union {
Byte bVal; // VT_UI1.
Short iVal; // VT_I2. <===== LOOK HERE !!!
long lVal; // VT_I4.
float fltVal; // VT_R4.
double dblVal; // VT_R8.... ... ...
};
};Hope this helps you! Daniel ;) --------------------------- Never change a running system!
-
Sorry, but I think I don't understand :omg: :-O !!! I have tested your code:
// variant.cpp : Definiert den Einsprungpunkt für die Konsolenanwendung.
//#include "stdafx.h"
#include <atlbase.h>
#include <list>typedef std::list<VARIANT> VARIANTLIST;
VARIANTLIST varList;int main(int argc, char* argv[])
{
for (int n = 0; n < 100; n++)
{
VARIANT var;
var.vt = VT_I2;
var.iVal = 1;varList.push\_back(var); } printf("size = %d \\n", (int) varList.size()); return 0;
}
There is all right with the code! I have a
std::list
ofVARIANT
and add 100 members ofVARIANT
to the list! The varList.size() function returns the count of elements in the list and so it returns 100 and that's right! TheVT_I2
says that theVARIANT
holdsshort
members. I2 says that the member is an integer who need 2 byte of space in the memory (sizeof(short) = 2
). Take a look in the MSDN:typedef struct tagVARIANT {
VARTYPE vt;
unsigned short wReserved1;
unsigned short wReserved2;
unsigned short wReserved3;
union {
Byte bVal; // VT_UI1.
Short iVal; // VT_I2. <===== LOOK HERE !!!
long lVal; // VT_I4.
float fltVal; // VT_R4.
double dblVal; // VT_R8.... ... ...
};
};Hope this helps you! Daniel ;) --------------------------- Never change a running system!