use _bstr_t. sometimes a combination of CComBSTR and _bstr_t will get you where you have to go.
i think ATL has a CString class that does some conversion like that too.
instead of C++ have you thought about using C# or VB.NET?
 
_bstr_t bst = "some string";
 
BSTR bs = bst.copy();
 
SysFreeString(bs);
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 22, 2004 1:11 PM
To: [EMAIL PROTECTED]
Subject: Visual Studio Axis Client

Hello,
 
I was wondering if anybody knows how to convert a basic string into a BSTR. I have read about this to great lengths online but am still receiving errors from Visual Studio.
 
Thanks,
James
 
In a message dated 7/22/2004 11:32:43 AM Eastern Standard Time, [EMAIL PROTECTED] writes:
Works like a charm. Thanks!
 
In a message dated 7/22/2004 11:30:33 AM Eastern Standard Time, [EMAIL PROTECTED] writes:
in order to see the contents of a bstr* you have to dereference the pointer.
you can also use _bstr_t to convert to a "regular" string.
hope this helps.
 
void GettaBSTR(BSTR* bstr) {
    *bstr = SysAllocString("some string");
    printf("this is the string: %S", *bstr);
}
 
BSTR bs;
GettaBSTR(&bs);
_bstr_t bst = bs;
printf("this is the string: %s", (const char*) bst);
std::string s = (const char*) bst;
printf("this is the string: %s", s.data());
SysFreeString(bs);
 
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 22, 2004 11:20 AM
To: [EMAIL PROTECTED]
Subject: Re: Visual Studio Axis Client

Does Anybody know how I can convert a BSTR* to a type that will output the contents of the String to the screen?
 
I am currently getting only what seems to be the address of the BSTR at the screen.
 
In a message dated 7/21/2004 5:43:55 PM Eastern Standard Time, [EMAIL PROTECTED] writes:
Are you using the MS SOAP toolkit or .NET?  Also, are you using Visual
Studio 6 or 7 (.NET)?

Jim

[EMAIL PROTECTED] wrote:

> Hello,

> I am creating a client for my axis web service in Visual Studio. By
> using Visual Studio to add a web reference, the program creates several
> data objects of type BSTR.

> I am wondering if anybody could give me a quick explanation why my
> Strings are getting placed as BSTR's, and one is being placed as a
> BSTR*. Now the BSTR* is becoming a complete obstacle because I don't
> even know how to get it initialized and I can't find anything on it.

> If somebody could give me a quick rundown of what I have to do to these
> BSTR's to get them initialized with the String values and how they'll
> run through axis, that'd be great.

> Thanks in advance.
> James Crosson
> [EMAIL PROTECTED]
 
 
 

Reply via email to