Results 1 to 6 of 6

Thread: what is equivalent to _bstr_t?

  1. #1
    Join Date
    May 2007
    Posts
    301
    Thanks
    46
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default what is equivalent to _bstr_t?

    Hi,

    I have a COM DLL I wrote in C# which I call from one of my MFC applications as follows:

    Qt Code:
    1. BOOL CDADcb::OpenDatabase( CString strFilename )
    2. {
    3. BSTR bstrName = strFilename.AllocSysString();
    4. m_bLoaded = m_spDCBParse->OpenDatabase( bstrName );
    5. return m_bLoaded;
    6. }
    To copy to clipboard, switch view to plain text mode 

    My problem is, what data type do I use as the BSTR using Qt4?

    Kind regards,
    Steve

  2. #2
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: what is equivalent to _bstr_t?

    Quote Originally Posted by steg90 View Post
    Hi,

    I have a COM DLL I wrote in C# which I call from one of my MFC applications as follows:

    Qt Code:
    1. BOOL CDADcb::OpenDatabase( CString strFilename )
    2. {
    3. BSTR bstrName = strFilename.AllocSysString();
    4. m_bLoaded = m_spDCBParse->OpenDatabase( bstrName );
    5. return m_bLoaded;
    6. }
    To copy to clipboard, switch view to plain text mode 

    My problem is, what data type do I use as the BSTR using Qt4?

    Kind regards,
    Steve
    By seeing your code, I think strFilename.AllocSysString() return QCString. Since there is no QCString in Qt4 you can use QByteArray. See qtassistance for more information.

  3. #3
    Join Date
    May 2007
    Posts
    301
    Thanks
    46
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: what is equivalent to _bstr_t?

    Hi,

    The AllocSysString returns a BSTR, but there doesn't seem to be an equivalent in Qt4? The code I'm showing is for MFC. I just want to know how I can call the OpenDatabase function which takes a _bstr_t data type, I don't know what the equivalent is in Qt.

    Regards,
    Steve

  4. #4
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: what is equivalent to _bstr_t?

    Quote Originally Posted by steg90 View Post
    Hi,

    The AllocSysString returns a BSTR, but there doesn't seem to be an equivalent in Qt4? The code I'm showing is for MFC. I just want to know how I can call the OpenDatabase function which takes a _bstr_t data type, I don't know what the equivalent is in Qt.

    Regards,
    Steve
    What is BSTR??? What is the return type??

  5. #5
    Join Date
    May 2007
    Posts
    301
    Thanks
    46
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: what is equivalent to _bstr_t?

    Hi,

    BSTR is OLECHAR*

    I have just done the following which works :

    Qt Code:
    1. BOOL CDADcb::OpenDatabase( CString strFilename )
    2. {
    3. m_bLoaded = FALSE;
    4. BSTR s = SysAllocString( (OLECHAR*)strFilename.unicode() );
    5. m_bLoaded = m_spDCBParse->OpenDatabase( s );//strFilename );
    6. SysFreeString( s );
    7. return m_bLoaded;
    8. }
    To copy to clipboard, switch view to plain text mode 

    Regards,
    Steve

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: what is equivalent to _bstr_t?

    Why not use the same type as in other C++ apps? You don't have to use Qt classes everywhere...

Similar Threads

  1. setRasterOp Equivalent
    By vermarajeev in forum Qt Programming
    Replies: 22
    Last Post: 31st March 2007, 13:13
  2. Replies: 2
    Last Post: 23rd April 2006, 01:02
  3. what's the equivalent with DPtoLP in windows
    By cocalele in forum Qt Programming
    Replies: 6
    Last Post: 1st March 2006, 06:57
  4. make install equivalent in qmake ...
    By momesana in forum Newbie
    Replies: 3
    Last Post: 20th February 2006, 21:46
  5. PostMessage() across process boundaries equivalent
    By TheKedge in forum Qt Programming
    Replies: 9
    Last Post: 27th January 2006, 00:02

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.