CodeGuru Forums -
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic Newsletters VB Forums Developer.com


Newest CodeGuru.com Articles:

  • Installing SQL Server 2008
  • Writing UDFs for Firebird Embedded SQL Server
  • [Updated] Shutdown Manager
  • Building Windows Azure Cloud Service Applications with Azure Storage and the Azure SDK

  • Search CodeGuru:
     



    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > Visual C++ Programming
    FAQ Members List Calendar Search Today's Posts Mark Forums Read

    Visual C++ Programming Ask questions about Windows programming with Visual C++ and help others by answering their questions.

    Closed Thread
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1    
    Old March 29th, 1999, 08:56 AM
    Berthold Hutten Berthold Hutten is offline
    Junior Member
     
    Join Date: Mar 1999
    Posts: 1
    Berthold Hutten is an unknown quantity at this point (<10)
    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    
    Old March 29th, 1999, 09:23 AM
    Daren Chandisingh Daren Chandisingh is offline
    Member
     
    Join Date: Apr 1999
    Posts: 32
    Daren Chandisingh is an unknown quantity at this point (<10)
    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    
    Old March 30th, 1999, 07:15 AM
    Rich Rich is offline
    Junior Member
     
    Join Date: Apr 1999
    Posts: 8
    Rich is an unknown quantity at this point (<10)
    Re: C++, VB ActiveX and VARIANT's



    How about


    VARIANT Var;


    CString strValue = Var.bstr;


    Or


    Var.bstr = strValue.AllocSysString();


    Good Luck


    Rich
    Closed Thread

    Bookmarks
    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > Visual C++ Programming


    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 07:51 PM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy


    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
    Copyright WebMediaBrands Inc. 2002-2009