Convert SYSTEMTIME to BSTR

B

banski

Hi,

Im trying to find out how to convert a SYSTEMTIME to BSTR. Cant find
out how to do that.
Hopefully some of you could help me out.

Best regards
Thomas
 
A

Aaron W. LaFramboise

Im trying to find out how to convert a SYSTEMTIME to BSTR. Cant find
out how to do that.

I'm assuming you're referring to the SYSTEMTIME struct in the Windows
API (The C++ equivilent is struct tm in <time.h>, which you should
consider using instead if appropriate.), and the BSTR struct which
represents a Visual Basic string, often used in COM/OLE.

Generally, the procedure here is to format from the time struct into
an ordinary std::string using std::eek:stringstream in whatever format
you require. Convert the std::string into a C string using the
c_str() member, and convert that C string into a BSTR using _bstr_t in
<comutil.h>, which most Windows compilers provide. Alternately, you
can use the BSTR manipulation functions that are part of the base OLE
API.

Whatever you do, don't just pass a C string as a BSTR. Even though
this will not generate a compile-time diagnostic, it is invalid, and
will lead to problems.

Aaron W. LaFramboise
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top