に* BSTR型のパラメータを渡すために、_bstr_tの使用:これを行うための正しい方法は何ですか機能
_bstr_t description;
errorInfo->GetDescription(&description.GetBSTR());
か:
_bstr_t description;
errorInfo->GetDescription(description.GetAddress());
IError:GetDescription
は次のように定義されて
:
HRESULT GetDescription (BSTR *pbstrDescription);
私は簡単にこれを行うことができます知っている:
BSTR description= SysAllocString (L"Whateva"));
errorInfo->GetDescription (&description);
SysFreeString (description);
おかげ
+1、他のインスタンスで共有されている_bstr_tのBSTRの話はそれに直接割り当てることができます何も私を先送りにします。 –
代入演算子の代わりに 'Attach()'を使うべきではありませんか? –
示すように、関数は 'GetDescription'は' SysAllocString'とtemp' 'にメモリを割り当て、そのメモリが解放されることはありません。どちらかが、あなたは 'SysFreeStringの(一時)'を呼び出す、もしくは 'wrap'は、そのメモリにアタッチし、それを解放することを確認する必要があります。 – abelenky