Skip to main content
gamedev.net
🔒 Locked

Using _bstr_t BSTR wrapper class?

Started by Promit 0 replies 700+ views
Original Post
Promit
Promit
Part 3 of my questions onabout the same topic. I''ve finally gotten C++ to (mostly)interact correctly with my VB ActiveX DLL. Problem is, string passing is kinda weird... I''m using #import directive and Smart COM pointers. The VB funcs that take strings are asking for an object of type _bstr_t, which is a wrapper for the wide character BSTR. At least, That''s what it looks like. I haven''t got any experience with writing Unicode compatible stuff. I''m trying to put basic text into this thing. I tried using swprintf with the second param as a string literal. It couldn''t make a string literal into a wchar_t. wchar_t is one of the types that I can give to the _bstr_t contructor and operator=. I can give it char* too, but I''m not sure that it is working, as my VB DLL does not seem to be getting the string. Any general help? ____________________________________________________________ Direct3D vs. OpenGL
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
DrPizza
DrPizza
_bstr_t has convenient overloads for adding character strings, if memory serves. I think it also converts between narrow and wide strings.

If you want a wide string literal, you prepend the single or double quote marks with an L.

e.g. std::wstring myWideString(L"This is wide");




[edited by - DrPizza on May 30, 2002 11:49:32 PM]
char a[99999],*p=a;int main(int c,char**V){char*v=c>0?1[V]:(char*)V;if(c>=0)for(;*v&&93!=*v;){62==*v&&++p||60==*v&&--p||43==*v&&++*p||45==*v&&--*p||44==*v&&(*p=getchar())||46==*v&&putchar(*p)||91==*v&&(*p&&main(0,(char**)(--v+2))||(v=(char*)main(-1,(char**)++v)-1));++v;}else for(c=1;c;c+=(91==*v)-(93==*v),++v);return(int)v;} /*** drpizza@battleaxe.net ***/

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.