Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. list of VARIANT

list of VARIANT

Scheduled Pinned Locked Moved ATL / WTL / STL
questionhelp
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bojinyu
    wrote on last edited by
    #1

    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.

    D B 2 Replies Last reply
    0
    • B bojinyu

      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.

      D Offline
      D Offline
      Daniel Strigl
      wrote on last edited by
      #2

      What do you mean with "then length of vatList is increased 1, but the comment is not right"? Daniel ;) --------------------------- Never change a running system!

      B 1 Reply Last reply
      0
      • B bojinyu

        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.

        B Offline
        B Offline
        bojinyu
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • D Daniel Strigl

          What do you mean with "then length of vatList is increased 1, but the comment is not right"? Daniel ;) --------------------------- Never change a running system!

          B Offline
          B Offline
          bojinyu
          wrote on last edited by
          #4

          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.

          D 1 Reply Last reply
          0
          • B bojinyu

            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.

            D Offline
            D Offline
            Daniel Strigl
            wrote on last edited by
            #5

            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 of VARIANT and add 100 members of VARIANT to the list! The varList.size() function returns the count of elements in the list and so it returns 100 and that's right! The VT_I2 says that the VARIANT holds short 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!

            B 1 Reply Last reply
            0
            • D Daniel Strigl

              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 of VARIANT and add 100 members of VARIANT to the list! The varList.size() function returns the count of elements in the list and so it returns 100 and that's right! The VT_I2 says that the VARIANT holds short 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!

              B Offline
              B Offline
              bojinyu
              wrote on last edited by
              #6

              Thanks Daniel S. I have remove the problem. All the code really run in the right way, the fault was my wrong checking. I check by the watch window of Visual Stdio. The results of the list element showed there are upset. Thanks again.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups