By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,243 Members | 1,141 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,243 IT Pros & Developers. It's quick & easy.

Convert SYSTEMTIME to BSTR

P: n/a
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

Jul 24 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
banski wrote:
Hi,

Im trying to find out how to convert a SYSTEMTIME to BSTR.


What are SYSTEMTIME and BSTR? They are not standard C++ types.

Jul 24 '05 #2

P: n/a
On 24 Jul 2005 07:16:53 -0700, "banski" <th********@hotmail.com>
wrote:
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::ostringstream 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

Jul 24 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.