PDA

Click to See Complete Forum and Search --> : Bstr


Technocrat
May 7th, 2001, 03:29 PM
I need some help with making a BSTR. I need to make two BSTR in to 1 and I can't seem to make it work. The finished product needs to look like this:
ItemOpen("ID")

ID is the other BSTR. So how I combine two BSTRs together?

I have tried:

BSTR cmd;
cmd = SysAllocString(L"ItemOpen(\"" & ID & "\")");


Thanks

parksie
May 7th, 2001, 04:06 PM
Do you specifically have to use BSTR? Actually, it's basically synonymous with LPWSTR (== wchar_t*). So, you can use the STL to help with this:

basic_string<OLECHAR> sMyStr;

Technocrat
May 7th, 2001, 06:19 PM
Yeah I dont have much of a choice, BSTR is what the functions I am using need. But I will try LPWSTR just to see what happens.

parksie
May 7th, 2001, 06:20 PM
What functions are they?

Technocrat
May 7th, 2001, 06:26 PM
They are Novell GroupWise functions. If you know anything about them you would be my hero. But it seems like no one does :D

parksie
May 7th, 2001, 06:29 PM
Hmm... not used that, sorry :(

BSTR is defined as OLECHAR FAR* which is basically OLECHAR*:

typedef basic_string<OLECHAR> BString;

BString x = L"Hello";
FunctionThatTakesBSTR(x.c_str());

Technocrat
May 7th, 2001, 06:33 PM
Ok so how would I make 2 of those into 1

Technocrat
May 7th, 2001, 06:36 PM
What libary is that in?
It barfs up an error on compile about missing a ; after basic_string

parksie
May 8th, 2001, 05:03 AM
#include <string>
using namespace std;

// ...

BString x = BString(L"Hello ") + BString(L"World");

Technocrat
May 8th, 2001, 11:21 AM
Because I could not get on to VB-World this morning I figured it out. *** is up with this server?? Seems like its got alot of problems. Anyways I used:


#include <atlbase.h>

CComBSTR cmd;

cmd = "ItemOpen(\"";
cmd += ID;
cmd += "\")";



And it work. But thanks for the suggestions.

parksie
May 8th, 2001, 11:58 AM
No problem. I was just trying to avoid bringing in ATL or MFC if I could help it :)

Technocrat
May 8th, 2001, 12:00 PM
On this program so would I, but I will take what works. ;)