I have a stand alone c++ program that uses SendMessage to communicate with
a stand alone C# program.
The c++ program looks like this
hWind has previously been determined;
wchar_t wts[] = L"123456";
::MessageBox(NULL,wts,L"",MB_OK); // just to display it gets set
SendMessage(hWind,WM_GET_ENG_UNITS_MESSAGE,0,(LPARAM)(&wts)); // send it
to the C# program
::MessageBox(NULL,wts,L"",MB_OK); // contents after the C# program
-----------------------------------------
The C# side catches the message and :
string EuS = Marshal.PtrToStringUni(msg.LParam);
EuS now reads correctly 123456
here lies my problem how can I minuplate the string on the c++ side from
the C# side by using the msg.LParam.
TIA
Ken
Robert Jordan - 26 Sep 2005 20:28 GMT
Hi Ken,
> I have a stand alone c++ program that uses SendMessage to communicate with
> a stand alone C# program.
[quoted text clipped - 20 lines]
> here lies my problem how can I minuplate the string on the c++ side from
> the C# side by using the msg.LParam.
You cannot do that. Even with 2 C++ apps. Your WM_GET_ENG_UNITS_MESSAGE
message is probably identical with a Window message that takes
a LPTSTR as a LPARAM parameter. That's why the pointer got mapped
at all.
If you want to safely exchange data between the apps, you have
to use WM_COPYDATA:
http://www.vbaccelerator.com/home/NET/Code/Libraries/Windows_Messages/Simple_Int
erprocess_Communication/article.asp
http://www.codeproject.com/csharp/wm_copydata_use.asp
Rob