Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Should I release any BSTR objects which the Inventor API gives me?

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
oransen
361 Views, 2 Replies

Should I release any BSTR objects which the Inventor API gives me?

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?

 

 




2 REPLIES 2
Message 2 of 3
wayne.brill
in reply to: oransen

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,

 



Wayne Brill
Developer Technical Services
Autodesk Developer Network

Message 3 of 3
oransen
in reply to: wayne.brill

Thanks! It makes sense, but I wanted to be sure.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report