최상단 광고

2012년 4월 11일 수요일

LPCTSTR -> BSTR 리턴 방법


//  LPCTSTR -> BSTR 리턴
STDMETHODIMP CStar::ProductInfoUpload(BSTR* pResult)
{
 LPCTSTR strTmp;

 *pResult = _com_util::ConvertStringToBSTR(strTmp); // 방법 1 (MS 버그, 메모리 릭이 있음)
 CComBSTR(CA2T(strTmp)).CopyTo(pResult); // 방법 2
 *pResult = CComBSTR(CA2W(strTmp)).Copy();  // 방법 3
}

댓글 없음: