Am I right in assuming that any BSTR objects returned to me from the Inventor API should be released with a call to SysFreeString?
And that rule should be followed whether I use a ->GetThingy() or ->get_Thingy() format?
Solved! Go to Solution.
Solved by wayne.brill. Go to Solution.
Hi,
I would say that you should use SysFreeString(). I find this done in several places in the Inventor SDK. One is in AtlAddinServer.h and in RevisionCloudCmd.cpp in this folder on my system:
C:\Users\Public\Documents\Autodesk\Inventor 2014\SDK\UserTools\DrawingTools\Source
HRESULT CRevisionCloudCmd::ChangeLabelName(CComPtr<DrawingSketch> pSketch)
{
BSTR DisplayName;
HRESULT hr = pSketch->get_Name(&DisplayName);
OnErrorReturn(FAILED(hr),hr);
CString ReplaceDisplayName;
int len = SysStringLen(DisplayName);
for(int i = 6;i<len;i++)
ReplaceDisplayName += DisplayName[i];
ReplaceDisplayName.Insert(0,_T(
"RevisionCloud"));
BSTR ReplacedDisplayName = ReplaceDisplayName.AllocSysString();
hr = pSketch->put_Name(ReplacedDisplayName);
SysFreeString(ReplacedDisplayName);
ATLASSERT(SUCCEEDED(hr));
SysFreeString(DisplayName);
return hr;
}
Thanks,
Can't find what you're looking for? Ask the community or share your knowledge.