Click here to Skip to main content
16,017,015 members
Home / Discussions / COM
   

COM

 
GeneralRe: COM Client problem Pin
Anonymous14-May-03 18:42
Anonymous14-May-03 18:42 
GeneralRe: COM Client problem Pin
valikac14-May-03 19:55
valikac14-May-03 19:55 
GeneralRe: COM Client problem Pin
balcn16-May-03 8:05
balcn16-May-03 8:05 
GeneralRe: COM Client problem Pin
Dudi Avramov18-May-03 23:11
Dudi Avramov18-May-03 23:11 
GeneralHelp : About Active Document Pin
twinkle_star13-May-03 16:59
twinkle_star13-May-03 16:59 
QuestionDifference between Webbrowser contorl and InternetExplorer object ? Pin
GriffonRL13-May-03 3:51
GriffonRL13-May-03 3:51 
QuestionCan a method of COM-server return a string pointer Pin
Bash12-May-03 19:52
Bash12-May-03 19:52 
AnswerRe: Can a method of COM-server return a string pointer Pin
justanotherprogrammer12-May-03 21:13
justanotherprogrammer12-May-03 21:13 
Hi,
I'm a novice too. But I have had the same problem. So maybe I can give you a hint.

As far as I know the best solution is to use the BSTR data type. This is not very complicated. There are only some special functions that you have to use: SysAllocString, SysFreeString, SysStringLen and some other ones. You could do it like this:

IDL:
GetStr([out] BSTR* str)

Method implementation:
STDMETHODIMP CAbc::GetStr(BSTR* str)
{
//Allocate memory for the BSTR
str = SysAllocString("string for COM");

//Check wether allocation was successful
if(str) return S_OK;
else return E_FAIL;
}

And the caller:
...
BSTR myBStr;
HRESULT hr = Abc->GetStr(myBStr);
if(FAILED(hr)) damned();
else
{
//Now you've got the string
//Do with it what ever you want (but don't get rude...)
//You can use it like a LPSTR as far as I know
printf("My String: %s", myBStr); //example
SetDlgItemText(IDC_EDIT, myBStr); //example

//But now it is your responsability to free the memory!
SysFreeString(myBStr);

//That's it
}
...

I hope this was all correct. Try it. It should work.
But maybe someone else can tell you more or correct my posting.

GeneralRe: Can a method of COM-server return a string pointer Pin
valikac13-May-03 16:01
valikac13-May-03 16:01 
GeneralRe: Can a method of COM-server return a string pointer Pin
Renjith Ramachandran15-May-03 5:57
Renjith Ramachandran15-May-03 5:57 
Generalactivex parent Pin
Shotgun12-May-03 15:28
Shotgun12-May-03 15:28 
GeneralSAFEARRAY question Pin
Stephane Routelous12-May-03 8:15
Stephane Routelous12-May-03 8:15 
GeneralRetrieving Pointer to IOleClientSite Pin
GeorgT12-May-03 4:15
GeorgT12-May-03 4:15 
GeneralUsing Updated Interface Pin
swarup12-May-03 3:17
swarup12-May-03 3:17 
Generalerror calling method in event Pin
particle2k11-May-03 23:44
particle2k11-May-03 23:44 
GeneralRe: error calling method in event Pin
Vi215-May-03 3:43
Vi215-May-03 3:43 
Generalexe-server component's interface related Pin
satishsilla11-May-03 20:54
satishsilla11-May-03 20:54 
GeneralRe: exe-server component's interface related Pin
valikac13-May-03 16:04
valikac13-May-03 16:04 
Generalexe-server component's interface related Pin
satishsilla11-May-03 20:53
satishsilla11-May-03 20:53 
GeneralMSHTML & IStream Pin
luda10-May-03 13:13
luda10-May-03 13:13 
GeneralRe: MSHTML & IStream Pin
Stephane Rodriguez.12-May-03 3:43
Stephane Rodriguez.12-May-03 3:43 
GeneralATL components Pin
Ancient Dragon9-May-03 13:00
Ancient Dragon9-May-03 13:00 
GeneralRe: ATL components Pin
valikac15-May-03 7:59
valikac15-May-03 7:59 
GeneralCustom Outlook property sheet (C#) Pin
rkiesler9-May-03 12:45
rkiesler9-May-03 12:45 
QuestionHow to get (and use) the IStream interface from CFile Pin
Anders Sandberg8-May-03 22:30
Anders Sandberg8-May-03 22:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.