CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 1999
    Posts
    1

    C++, VB ActiveX and VARIANT's



    Hi,


    I'm not a very well C++ programmer, and I have the following problem:

    I've a VB activex with successfully is merged with my C++ project. So far no problem. But now I want to invoke a method of the VB ActiveX, the method looks like:


    virtual /* [id] */ HRESULT __stdcall GetValue(

    /* [in] */ VARIANT sCategory,

    /* [in] */ VARIANT sName,

    /* [defaultvalue][optional][in] */ VARIANT sDefault,

    /* [retval][out] */ VARIANT __RPC_FAR *__MIDL_0015) = 0;


    The method call would be something like:


    mGlobals->GetValue(sCategory, sName, sDefault, RetVal);


    My problem is type casting between the VARIANT's and some CString's I have.

    Can somebody give me an example of how the convert VARIANT's to CString's or any other type I can better use. (I can use some tips on with type to use for strings).


    Thanks in advance.


    Regards,

    Berthold Hutten



  2. #2
    Join Date
    Apr 1999
    Posts
    32

    Re: C++, VB ActiveX and VARIANT's



    I don't know the *best* way, but this should work:


    ----

    VARIANT sValue;


    // construct a new _bstr_t from the VARIANT

    _bstr_t bstrVal(sValue);


    // construct a new CString using the char * operator on the _bstr_t object.

    CString strVal((char *)(bstrVal));




  3. #3
    Join Date
    Apr 1999
    Posts
    8

    Re: C++, VB ActiveX and VARIANT's



    How about


    VARIANT Var;


    CString strValue = Var.bstr;


    Or


    Var.bstr = strValue.AllocSysString();


    Good Luck


    Rich

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured