G
Guest
I have a C++/CLI app that uses a logging control in an ATL COM Server. C++
Interop seems to work just fine to pass data from the C++/CLI app to the ATL
Control but I can't seem to figure out how to get a string value back from
the ATL Control. When debugging the code seen below, I see that the VARIANT
pointed to by 'data' is updated but the String 'str' passed from the C++/CLI
app doesn't change. So the String 'str' seems to be passed by value rather
than reference but I can't seem to get anything else to work without throwing
out C++ interop. Any suggestions?
System::Void button2_Click(System::Object^ sender, System::EventArgs^ e)
{
System::String^ str("temp");
this->axLogCtl1->GetLogText(str);
richTextBox1->Text = str;
}
HRESULT LogCtl::GetLogText(VARIANT* data)
{
CComVariant v(m_strData);
/////////////////////////////////////////////////////////////////
// Pass the current log data to the caller.
/////////////////////////////////////////////////////////////////
if (VT_BSTR == data.vt)
v.CopyTo(&(data.bstrVal));
return (S_OK);
}
Interop seems to work just fine to pass data from the C++/CLI app to the ATL
Control but I can't seem to figure out how to get a string value back from
the ATL Control. When debugging the code seen below, I see that the VARIANT
pointed to by 'data' is updated but the String 'str' passed from the C++/CLI
app doesn't change. So the String 'str' seems to be passed by value rather
than reference but I can't seem to get anything else to work without throwing
out C++ interop. Any suggestions?
System::Void button2_Click(System::Object^ sender, System::EventArgs^ e)
{
System::String^ str("temp");
this->axLogCtl1->GetLogText(str);
richTextBox1->Text = str;
}
HRESULT LogCtl::GetLogText(VARIANT* data)
{
CComVariant v(m_strData);
/////////////////////////////////////////////////////////////////
// Pass the current log data to the caller.
/////////////////////////////////////////////////////////////////
if (VT_BSTR == data.vt)
v.CopyTo(&(data.bstrVal));
return (S_OK);
}