Convert CString to BSTR
-
Dear All, Unable to convert CString to BSTR! Am I a stupid?! :mad: I have an interface method which needs to convert CString to BSTR and return BSTR to caller. AllocSysString of CString is not copying the data to BSTR.
STDMETHODIMP CTP_Interface_ErrorCode_Wrp::GetAdditionalDataFlag(BSTR *AddDataFlag) { AFX_MANAGE_STATE(AfxGetStaticModuleState()) // TODO: Add your implementation code here CString temp = pTP_Interface_ErrorCode->GetAdditionalDataFlag(); *AddDataFlag = temp.AllocSysString(); return S_OK; }
Any one please help me. Thanks very much, Nani -
Dear All, Unable to convert CString to BSTR! Am I a stupid?! :mad: I have an interface method which needs to convert CString to BSTR and return BSTR to caller. AllocSysString of CString is not copying the data to BSTR.
STDMETHODIMP CTP_Interface_ErrorCode_Wrp::GetAdditionalDataFlag(BSTR *AddDataFlag) { AFX_MANAGE_STATE(AfxGetStaticModuleState()) // TODO: Add your implementation code here CString temp = pTP_Interface_ErrorCode->GetAdditionalDataFlag(); *AddDataFlag = temp.AllocSysString(); return S_OK; }
Any one please help me. Thanks very much, NaniCross Post => Cross Answer http://www.codeproject.com/script/Forums/View.aspx?fid=4486&msg=2386375[^] :-D
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
[my articles]