i am trying to send a string to another application.
the way i am trying to do this is by using the SendMessage function in the windows api, and i am setting the WParam parameter to a string value(when i imported the function i did use a string type for this parameter).
now in the receiving app i have it setup to receive the message and to put the contents of the WParam value into a textbox, but the problem is it doesn't have a string(i used a test string of "Hello World!") it just has a bunch of numbers and it puts those numbers into the text box. so what am i doing wrong?
here is the code i am using in my sending app:
these are the parameters i am using for the SendMessage Method
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern string SendMessage(int hWnd, int msg, string wParam, IntPtr lParam);
and this line is ran when a button in the form is clicked:
ParentFormHandle = ParentHandle.ToInt32();
SendMessage(ParentFormHandle, 40, "Hello World!", IntPtr.Zero);
this is the code i am using in the reciving app:
protected override void WndProc(ref Message m)
if (m.Msg == 40)
YourTextBoxNameHere.Text += m.WParam.ToString();
here is the result of the WParam property with the string "Hello World!":
now every time i close the sending app and open it back up again this value will change.
if anyone has a better way to send a string to an application please let me know.
thanks for all of your help in advance,