Re: trouble converting BSTR
You probably need to link with comsuppw.lib.
Re: trouble converting BSTR
Re: trouble converting BSTR
the problem i have with using comsuppw.lib is that it's a vc++ lib and i can't use it(as far as i know) with borland. i could use implib but there's no comsuppw.dll.
Re: trouble converting BSTR
I think I remember that in one of my projects, the only solution I could come up with was to copy the code of _com_util::... which I found somewhere on the net. Back then I either did not know which lib to link to or I didn't find it. Maybe copying the code is an option for you as well?
Re: trouble converting BSTR
BSTR is just a wide character string with a few differences: it may not have a NULL terminator, or may have embedded NULLS; it has a DWORD allocated just before the actual pointer returned that contains the length of the string. You can usually ignore those differences in the majority of cases (in practice they can be treated as "wide" character strings). A simple cast to wchar_t * (does Borland have the wchar_t type?) should do the trick. If you want to use std C++ containers, use a std::wstring.
How is the BSTR being returned from the itunes API? DO you allocate it your self (with SysAllocStr) or is it passed from the API and must be deallocated? Do you deallocate it, or does the API?
Re: trouble converting BSTR
you raised some good questions hoxiesw: from everything I've seen you don't need to use sysallocate(and as far as i know i don't need to deallocate it), you initialize the bstr to 0, then i'm passing the pointer to that in the function call.
Code:
BSTR bstr = 0;
obj->get_Name((BSTR *)&bstr);
another thing i found is coff2omf, however the output file is like 1kb. i saw some post on other forums where they said the format changed with VC++ 6 and that you have to convert the lib file to a previous version using vc++ tool - link /lib /convert comsuppw.lib - when i tried that it says /convert is unrecognized.
Re: trouble converting BSTR
Hi guys, so (lol) I believe I got it working literally 5min after my last post: here's what works(thanks 2 hoxsiew):
Code:
wchar_t *wch;
wch = (wchar_t *)track_str;
wcout << wch << endl;