Hi everybody,
I have a legacy program at work that I have taken over and my boss wants me to add some functionality. I have already added a com object to the program and am producing a functional dll which I can write strings to and control my program. I however am having huge difficulties reading strings back from dll into my vb.net application. I have been googling for a week or so and have admittedly found a couple of examples but none of which solve my problem or even get me a bit closer.
The c++ side of life:
BSTR STDMETHODCALLTYPE Diag_Receive(BSTR* message);
BSTR STDMETHODCALLTYPE TExtensionCordComImpl::Diag_Receive(BSTR* message)
{
try
{
BSTR bstMessage=NULL;
bstMessage=SysAllocStringByteLen(NULL,(sizeof(ExtCordMainForm->TxDiagMessageRxEdit->Text)*2)+1);
HexFromBin((LPBYTE)(BSTR)ExtCordMainForm->TxDiagMessageRxEdit->Text.c_str(),sizeof(ExtCordMainForm->TxDiagMessageRxEdit->Text),(LPSTR)bstMessage);
*message=(BSTR)(ExtCordMainForm->TxDiagMessageRxEdit->Text.c_str() );
return bstMessage;
}
catch(Exception &e)
{
//return (BSTR)"NULL";
}
};
The .net side of life:
Public Declare Ansi Function GetDiag Lib "D:\Documents and Settings\meberlein\My Documents\Computer Switch\Visual Studio 2008\Projects\ComUnitTest\ComUnitTest\obj\Debug\Interop.ExtensionCord.dll" (<MarshalAs(UnmanagedType.BStr)> ByVal message As String) As String
Dim str As String = "Version Info OMAP"
Dim message As String = ""
Dim rtnmessage As String = ""
ExtensionCord.Diag_Send(str)
Threading.Thread.Sleep(1000)
Try
rtnmessage = GetDiag(message)
Catch ex As Exception
End Try
Me.Text = message + " " + rtnmessage
Any help is greatly appreciated.
Sincerely,
Mike