sendMessage from a .Net App
OK, I am stuck :tard: . I am trying to talk to RR from a C# application. I want to use sendMessage but I am stuck. sendMessage uses stuff that is unsafe in .Net and also has some pointer data which is a nightmare for me to code. I've looked at the Delphi & VB6 examples and this is as close as I can get the code in C#. So my questions are:
1. Has anyone written sendMessage for RR in a .Net language?
2. Guino, is it possible to create a new method that is easier for me to use than sendMesssage.
public class COPYDATASTRUCT
public int dwData = 0;//32 bit int to passed. Not used.
public int cbData = 0;//length of string. Will be one greater because of null termination.
public IntPtr lpData;//string to be passed.
public COPYDATASTRUCT(string Data)
lpData = Data + "/0"; //add null termination
cbData = lpData.Length; //length includes null chr so will be one greater
[DllImport("User32.dll")] public static extern IntPtr SendMessage( int hwnd, int uMsg, int wParam, COPYDATASTRUCT lParam);
[DllImport("user32.dll") ] static extern int FindWindow (string lpClassName,string WindowName);
private static int _messageID = 1163005939;
public const int WM_COPYDATA = 0x4A;
public void PluginSendMessage(string windowname, string className, string message)
hWnd = FindWindow ("ThunderRT6FormDC","RoadRunner");
SendMessage(hWnd, WM_COPYDATA, 0, new COPYDATASTRUCT(message));
One solution I thought of was to write a DLL in Delphi or VB6 using the slightly modified example code. Then I can add this DLL to the .Net app ad call the DLL to make the sendMessage code. But I don't have Delphi or VB6 tools to create the DLL. Can someone thrash together a small DLL with two public methods:
int winHandler = FindWindow(string lpClassName,string WindowName)
SendMessage(int winHandler, string message)
With this DLL I can call RR or any other App that uses sendMessage.
All help on this is greatly appreciated! I'm stuck :confused: