process communication between vb6 and c#
Hello,
i have two applications (once in vb6 and once in c#) which have to communicate together. They have to send and receive strings.
I used api-method sendmessage, but it doesn't work.
in vb:
Private Declare Function SendMessageByStr& Lib "user32" Alias "SendMessageA" _
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal _
lParam As String)
[..]
Call SendMessageByStr(hwndTarget, MessageId, 4, "test")
in C#:
unsafe protected override void WndProc(ref Message m)
{
if (m.Msg == VB6_TO_CSHARP_MessageId.ToInt32())
{
try
{
string url = new string((char*)(m.LParam.ToPointer()), 0, m.WParam.ToInt32());
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
base.WndProc(ref m);
}
There is an exception by reading string. Has anyone sourcecode to send and receive strings from VB6 and C# applications?
As an example project use this from codeproject (this project only send normaly messages, no strings):
http://www.codeproject.com/dotnet/VB6andVBNETWindowMessages.asp
Can you help?
Sincerely,
Andre