|
-
April 19th, 1999, 06:45 AM
#1
[COM] How to get BSTR from COM
I want to receive string from COM component.
<IDL>
HRESULT Test([out, string] BSTR* abc);
<Test Server>
HRESULT Test(/*out, string*/ BSTR* abc)
{
_bstr_t bstrResult(abc, false);
bstrResult = L"This is a test";
abc = (BSTR)bstrResult;
return S_OK;
}
<Test Client : VB>
Dim obj as new WebCom
Dim s as String
obj.Test s
---------------
But, this code occurs error (in MTS).
How COM server pass BSTR string to client?
A programmer who loves Goethe.
-
April 19th, 1999, 07:06 AM
#2
Re: [COM] How to get BSTR from COM
See SysAllocString, SysFreeString, OLE2T, T2OLE, USES_CONVERSION
Sincerely, Mihai
-
April 19th, 1999, 08:01 AM
#3
Re: [COM] How to get BSTR from COM
Since _bstr_t performs all of your allocation for you I believe you can do something like this:
HRESULT Test(/*out, string*/ BSTR* abc)
{
_bstr_t bstrResult;
bstrResult = L"This is a test";
abc = bstrResult.copy();
return S_OK;
}
-
April 19th, 1999, 08:26 AM
#4
Re: [COM] How to get BSTR from COM
-
April 21st, 1999, 02:49 PM
#5
Re: [COM] How to get BSTR from COM
_bstr_t bstrResult(abc, false);
bstrResult = L"This is a test"; // Wrong
Try to do this.
wchar_t wbst[]= L"This is a test";
abc = SysAllocString(wbst);
I hope this will help you.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|