Official BS.Player forums

Official BS.Player forums (http://forum.bsplayer.com/index.php)
-   General Talk And Support (http://forum.bsplayer.com/forumdisplay.php?f=8)
-   -   c#.net wrapper for pinvoke calls for sdk (http://forum.bsplayer.com/showthread.php?t=8851)

MaartenKoops 6th May 2008 07:48 PM

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!!

Tizio 7th May 2008 09:22 AM

Hi MaartenKoops
Here you can find few programming threads that have been posted on this forum in the past years:
http://www.bsplayer.com/forum/viewtopic.php?t=7469
http://www.bsplayer.com/forum/viewtopic.php?t=9890
http://www.bsplayer.com/forum/viewtopic.php?t=6752

I hope at least one of these can help you in your project..
Anyway I never programmed in C#, only in C and VB, but there could be problems in your code.. First of all, I suggest you to check if you really get BSplayer's handle IntPtr windowHandler = PInvokeWindow.FindWindow("BSPlayer"); , if it's greater than 0 you found it, otherwise there's a problem. Plus BSPlayer is the name of the Class of BSplayer control window (its window name is "BSplayer") and the name of the Window of BSplayer video window (its class is "BSPVideoWindow"), maybe you should take the handle to it by searching for Window+Class (I don't remember if it's case sensitive, but if this is the case, you can't get the handle to bsplayer window until a video window is displayed, and you can't pass commands to BSplayer)

What hWndDest is there for? you should only pass the pointer to the window (or in C# you have to do this?? I don't know.. :roll: )

As a test, maybe start to send a simpler command, such as PAUSE, PLAY or similar instructions (there you don't have to pass strings and in my opinion it's simpler to find a problem in your own code) :wink:

I hope you'll be successful in your project, and if this happen please post here how you fixed it.
Bye

MaartenKoops 7th May 2008 12:40 PM

Tizio, Thank you for your reply!!!!

The articles look very useful, Why didn’t I found the articles? I search the forum for "c#" etc, but the search result did not come back to me it the articles 1 and 3 you direct me to go to.

Anyhow, thank you! I will try to make it to work tonight!

Tizio 8th May 2008 06:14 PM

No problem.. I found them because I knew what to search since I already read them before :p
If you need more help feel free to post here..I hope to be helpful to you. Good work ;)


All times are GMT +1. The time now is 08:02 AM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
Ad Management plugin by RedTyger


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20