c#.net wrapper for pinvoke calls for sdk
Hi everyone!
I found the C++ documentation for the SendMessage calls in de SDK directory. That’s nice, but…..
I try to make the sendmessage work whit pinvoke calls in C#.net, but I can’t get it to work. Haze someone manage to make this work? Does someone already made a runtime callable wrapper for the sendmessage commands in C#.net.
Or does someone want to share a working sendmessage (via pinvoke) in C# example code?
The documentation says this: // COPYDATASTRUCT cds;
//
// cds.dwData=BSP_OpenFile;
// cds.lpData=(void *) "file.avi";
// cds.cbData=strlen((char *)cds.lpData)+1;
// SendMessage(bsp_hand,WM_COPYDATA,0,(LPARAM)&cds);
// available in BSPlayer version 0.84.484+
//
// Open file
#define BSP_OpenFile 0x10108
I tried the following: [DllImport("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int wMsg, int wParam, COPYDATASTRUCT lParam);
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[StructLayout(LayoutKind.Sequential)]
public class COPYDATASTRUCT
{
public int dwData = 0x10108;
public int cbData = 0;
public string lpData;
public COPYDATASTRUCT()
{
}
public COPYDATASTRUCT(string Data)
{
lpData = Data + "\0";
cbData = lpData.Length;
}
}
const int WM_COPYDATA = 0x4A;
public static void SendMsgString()
{
IntPtr windowHandler = PInvokeWindow.FindWindow("BSPlayer");
SendMessage(windowHandler hWndDest, WM_COPYDATA, 0, new COPYDATASTRUCT(@"c:\somefile.avi"));
}
The code is running, but the bsplayer is not responding. I have BS player PRO Version 2.14.942.
I hope to hear form you soon!!
|