PDA

View Full Version : what is equivalent to _bstr_t?



steg90
14th May 2007, 07:47
Hi,

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



BOOL CDADcb::OpenDatabase( CString strFilename )
{
BSTR bstrName = strFilename.AllocSysString();
m_bLoaded = m_spDCBParse->OpenDatabase( bstrName );
return m_bLoaded;
}


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

Kind regards,
Steve

vermarajeev
14th May 2007, 08:09
Hi,

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



BOOL CDADcb::OpenDatabase( CString strFilename )
{
BSTR bstrName = strFilename.AllocSysString();
m_bLoaded = m_spDCBParse->OpenDatabase( bstrName );
return m_bLoaded;
}


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.

steg90
14th May 2007, 08:18
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

vermarajeev
14th May 2007, 08:45
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??

steg90
14th May 2007, 09:11
Hi,

BSTR is OLECHAR*

I have just done the following which works :



BOOL CDADcb::OpenDatabase( CString strFilename )
{
m_bLoaded = FALSE;
BSTR s = SysAllocString( (OLECHAR*)strFilename.unicode() );
m_bLoaded = m_spDCBParse->OpenDatabase( s );//strFilename );
SysFreeString( s );
return m_bLoaded;
}


Regards,
Steve

wysota
14th May 2007, 09:57
Why not use the same type as in other C++ apps? You don't have to use Qt classes everywhere...