Who is responsible for allocating strings in COM calls?
For instance, if I have a method with an [out] BSTR* parameter, do I have to call AllocSysString and/or SysFreeString to pass it out? Same question for [out,retval]'s. i.e.:
STDMETHODIMP CESValhalla::GetFolderById(long lFolderId, BSTR *bsFolderName/*out*/, BSTR *bsFolderDescription/*out,retval*/)
{
*bsFolderName = CString("Name".AllocSysString();
*bsFolderDescription = CString("Description".AllocSysString();
return(S_OK);
}
Is this correct, or should I be doing something else? Sometimes unexpected things happen once in a while, like both BStr's will end up saying "Name" or both will end up saying "Description". How should I be doing this?
Same question for firing COM events. Should I do this:
Fire_OnFileScoutProgress(csPath.AllocSysString());
or what? Who's responsible for doing what for COM parameter strings?
~BenDilts( void );
For instance, if I have a method with an [out] BSTR* parameter, do I have to call AllocSysString and/or SysFreeString to pass it out? Same question for [out,retval]'s. i.e.:
STDMETHODIMP CESValhalla::GetFolderById(long lFolderId, BSTR *bsFolderName/*out*/, BSTR *bsFolderDescription/*out,retval*/)
{
*bsFolderName = CString("Name".AllocSysString();
*bsFolderDescription = CString("Description".AllocSysString();
return(S_OK);
}
Is this correct, or should I be doing something else? Sometimes unexpected things happen once in a while, like both BStr's will end up saying "Name" or both will end up saying "Description". How should I be doing this?
Same question for firing COM events. Should I do this:
Fire_OnFileScoutProgress(csPath.AllocSysString());
or what? Who's responsible for doing what for COM parameter strings?
~BenDilts( void );