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. C / C++ / MFC
  4. why VARIANT,BSTR in ActiveX?

why VARIANT,BSTR in ActiveX?

Scheduled Pinned Locked Moved C / C++ / MFC
c++comquestion
7 Posts 4 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.
  • L Offline
    L Offline
    lgatcodeproject
    wrote on last edited by
    #1

    Hello, When we write an Activex using VC++ what are the data types we should use? In one sample code I saw VARIANT, BSTR datatypes used mostly. y we should use this datatypes? Is there any specific datatypes that we are supossed to use along with Activex? Kindly clarify. Regards, LG

    lgatcodeproject

    CPalliniC M 2 Replies Last reply
    0
    • L lgatcodeproject

      Hello, When we write an Activex using VC++ what are the data types we should use? In one sample code I saw VARIANT, BSTR datatypes used mostly. y we should use this datatypes? Is there any specific datatypes that we are supossed to use along with Activex? Kindly clarify. Regards, LG

      lgatcodeproject

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #2

      lgatcodeproject wrote:

      . y we should use this datatypes?

      They are automation data types, see, for instance [^]. :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

      In testa che avete, signor di Ceprano?

      1 Reply Last reply
      0
      • L lgatcodeproject

        Hello, When we write an Activex using VC++ what are the data types we should use? In one sample code I saw VARIANT, BSTR datatypes used mostly. y we should use this datatypes? Is there any specific datatypes that we are supossed to use along with Activex? Kindly clarify. Regards, LG

        lgatcodeproject

        M Offline
        M Offline
        Matthew Faithfull
        wrote on last edited by
        #3

        VARIANT and BSTR get used because they are compatible with 'automation'. What this means in practice is the interfaces can be called from languages like Visual Basic which only have automatic marshalling and can be called from C++ without writing any marshalling code. BSTR is essentially the same as VBs internal String class so it can make using the control from VB easy enough that even a VB programmer might manage it. :-D What type you use in your interface when creating ActiveX controls really depends on what clients you need to support.

        "The secret of happiness is freedom, and the secret of freedom, courage." Thucydides (B.C. 460-400)

        L 1 Reply Last reply
        0
        • M Matthew Faithfull

          VARIANT and BSTR get used because they are compatible with 'automation'. What this means in practice is the interfaces can be called from languages like Visual Basic which only have automatic marshalling and can be called from C++ without writing any marshalling code. BSTR is essentially the same as VBs internal String class so it can make using the control from VB easy enough that even a VB programmer might manage it. :-D What type you use in your interface when creating ActiveX controls really depends on what clients you need to support.

          "The secret of happiness is freedom, and the secret of freedom, courage." Thucydides (B.C. 460-400)

          L Offline
          L Offline
          lgatcodeproject
          wrote on last edited by
          #4

          Thanks for the reply. If my client is in C sharp that what types I am supossed to use? Regards, LG

          lgatcodeproject

          P M 2 Replies Last reply
          0
          • L lgatcodeproject

            Thanks for the reply. If my client is in C sharp that what types I am supossed to use? Regards, LG

            lgatcodeproject

            P Offline
            P Offline
            prasad_som
            wrote on last edited by
            #5

            You need to use BSTR only. And Client can use datatype compatible to it. for C# String class can be used. Intellisense will tell you about datatype need to be used by client.

            1 Reply Last reply
            0
            • L lgatcodeproject

              Thanks for the reply. If my client is in C sharp that what types I am supossed to use? Regards, LG

              lgatcodeproject

              M Offline
              M Offline
              Matthew Faithfull
              wrote on last edited by
              #6

              If I were you I'd ask a C# programmer, perhaps on the C# forum, I have NO idea, sorry.

              "The secret of happiness is freedom, and the secret of freedom, courage." Thucydides (B.C. 460-400)

              L 1 Reply Last reply
              0
              • M Matthew Faithfull

                If I were you I'd ask a C# programmer, perhaps on the C# forum, I have NO idea, sorry.

                "The secret of happiness is freedom, and the secret of freedom, courage." Thucydides (B.C. 460-400)

                L Offline
                L Offline
                lgatcodeproject
                wrote on last edited by
                #7

                Thanks for the concern. Regards, LG

                lgatcodeproject

                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