sendMessage from a .Net App

OK, I am stuck . 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.

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:

dwdata Must be 1 (one=string) for it to work... when you can't declare a simple struct type in a language, I truly believe things have blown up to hell ..

optionally, you can send any command to RR by finding the active (displayed) window and simulating keypresses into it like: "PLAY" or "NEXT" (including quotes). but if you're not detailed enough to select RR's window, it may end up sending keypresses to other applications you don't want to..

PS: It's not possible to make a DLL to perform what you want because in VB you must compile the application with the appropriate window name or it won't be effective to receive any incomming messages.

C# is an OK language it just likes to make native Windows stuff really nasty to code. It gives little joy when needing Win32 APIs, like sendMessage. If anyone want the stub code I've written in C# use sendMessage with RR PM me.

Does anyone want to help me debug this? I'm doing something similar.. My problem is i see a few examples where lpData is an Int and some where it is an IntPtr. I don't know what to send to SendMessage. When i use IntPtr and change the datatype of VarPtr from Int to IntPtr, the message is sent but doesn't do anything. When i change everything to an Int, i don't force any datatypes, but i get the error:

A call to PInvoke function 'WindowsApplication2!WindowsApplication2.Form1::Se ndMessage' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.

My best guess is that you can't Alloc the space for the data you're referencing (with .Alloc) then free the memory before using it on the SendMessage call... you'd probably have to do the .free call AFTER the sendmessage...

I am puzzled as to what difference you're making from receiving 'messages' or 'values' from RR.. the only 'messages' you'd receive from RR are those containing 'values' you've requested from it (i.e. using request).. are you trying to use the 'sendmsg' command from the skin to control your application ? is that it ? because if so, there are ways of not needing that and using actually simpler commands for you to execute from your application using the COM SDK... here's a generic example of the COM interface in C# compared to the VB6 interface:

You can probably make procedures to call those functions (.Execute, .GetInfo and .GetInd) just so you avoid typing all that useless stuff.. once you created the SDK object, you can keep it until your program is finished with it.

in regards to the sendmessage version of this all, here's a supposedly "working" example of how to use the WM_COPYDATA message from C#: