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. dual interface

dual interface

Scheduled Pinned Locked Moved C / C++ / MFC
questioncom
63 Posts 7 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.
  • S Scott Holt

    Well, actually, I never said that. You are absolutely correct - you CAN represent BSTR and long integer in a VARIANT. BUT...you don't have to. You can pass a BSTR (or long integer) between a COM client and a COM server without first putting it into a VARIANT. I think a lot of COM programmers, to keep things simple and consistent, probably just use VARIANTs for everything. Scott :)

    G Offline
    G Offline
    George_George
    wrote on last edited by
    #61

    I agree, Scott! One more question, long integer you mean what data type? Could you write the related name in source codes (C++ and IDL) please? regards, George

    S 1 Reply Last reply
    0
    • G George_George

      I agree, Scott! One more question, long integer you mean what data type? Could you write the related name in source codes (C++ and IDL) please? regards, George

      S Offline
      S Offline
      Scott Holt
      wrote on last edited by
      #62

      In C/C++, a long integer is a four-byte integer value. If you study the valid values for the 'vt' member of a VARIANT (type of variant), you'll notice that the values for four-byte integer are 'VT_I4' (signed four-byte integer) and 'VT_UI4' (unsigned four-byte integer). I'm not sure how VB and C# let you set the variant type, but C++ has a '_variant_t' class that wraps VARIANT and has assignment operators that set it for you, or you can simply set it yourself. In C++, a long integer variable is declared as: long lMyVariable = 0 ; In IDL, you use the "long" keyword, as in these examples: [id(65), helpstring("Load an account from the database for a specific EMS/ambulance run.")] HRESULT LoadForRun( [in] long lAmbRunID, [out] long* plAccountID) ; [id(43), helpstring("Get the first condition indicator for an EMS/ambulance run.")] HRESULT GetFirstConditionIndicator( [out, string] BSTR* pbstrConditionIndicator, [out] long* plConditionIndicatorID) ; Notice that the parameters are of type "BSTR" and "long" (the asterisk, of course, means that a given parameter is actually a pointer to a BSTR or a long). Scott :)

      G 1 Reply Last reply
      0
      • S Scott Holt

        In C/C++, a long integer is a four-byte integer value. If you study the valid values for the 'vt' member of a VARIANT (type of variant), you'll notice that the values for four-byte integer are 'VT_I4' (signed four-byte integer) and 'VT_UI4' (unsigned four-byte integer). I'm not sure how VB and C# let you set the variant type, but C++ has a '_variant_t' class that wraps VARIANT and has assignment operators that set it for you, or you can simply set it yourself. In C++, a long integer variable is declared as: long lMyVariable = 0 ; In IDL, you use the "long" keyword, as in these examples: [id(65), helpstring("Load an account from the database for a specific EMS/ambulance run.")] HRESULT LoadForRun( [in] long lAmbRunID, [out] long* plAccountID) ; [id(43), helpstring("Get the first condition indicator for an EMS/ambulance run.")] HRESULT GetFirstConditionIndicator( [out, string] BSTR* pbstrConditionIndicator, [out] long* plConditionIndicatorID) ; Notice that the parameters are of type "BSTR" and "long" (the asterisk, of course, means that a given parameter is actually a pointer to a BSTR or a long). Scott :)

        G Offline
        G Offline
        George_George
        wrote on last edited by
        #63

        Thanks Scott, What do you want to express by the below statements? C# and VB does not support 4-byte integer or?? -------------------- In C/C++, a long integer is a four-byte integer value. If you study the valid values for the 'vt' member of a VARIANT (type of variant), you'll notice that the values for four-byte integer are 'VT_I4' (signed four-byte integer) and 'VT_UI4' (unsigned four-byte integer). I'm not sure how VB and C# let you set the variant type, -------------------- regards, George

        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