loyaliser
asked on
Converting data types (again)...
I have this function in some .h file included in my ATL COM program:
function(char *);
and need to pass this variable in the ATL COM code into the "char *" part of the above function:
BSTR SomeData;
How do I do that?
So, I need to call this function in my ATL COM code like this:
BSTR SomeData;
// Conver BSTR to char (what is the code needed here)
function(charOfSomeData);
Thanks...
function(char *);
and need to pass this variable in the ATL COM code into the "char *" part of the above function:
BSTR SomeData;
How do I do that?
So, I need to call this function in my ATL COM code like this:
BSTR SomeData;
// Conver BSTR to char (what is the code needed here)
function(charOfSomeData);
Thanks...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I hope you don't mind, but what would be the code for doing it the other way around... char [] to BSTR?
Thanks...
Thanks...
Use the ATL conversion macro A2BSTR.
USES_CONVERSION;
A2BSTR();
Or, simply use _bstr_t since it has a constructor
_bstr_t( const char* s2 ) throw( _com_error );
and use _bstr_t in place of BSTR.
You may also use CComBSTR class in ATL.
USES_CONVERSION;
A2BSTR();
Or, simply use _bstr_t since it has a constructor
_bstr_t( const char* s2 ) throw( _com_error );
and use _bstr_t in place of BSTR.
You may also use CComBSTR class in ATL.
ASKER