Official BS.Player forums  

Go Back   Official BS.Player forums > Main forum > General Talk And Support
Register FAQ Calendar Today's Posts Search

General Talk And Support General talk and peer-to-peer support about BS.Player and other video and audio multimedia players.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 6th May 2008
Junior Member
BS.Player Newbie
 
Join Date: May 2008
Posts: 2
Rep Power: 0
MaartenKoops is an unknown quantity at this point
Default 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!!
Reply With Quote
  #2 (permalink)  
Old 7th May 2008
Moderator
BS.Player Master
 
Join Date: Nov 2003
Location: Italy
Posts: 3,037
Rep Power: 28
Tizio will become famous soon enough
Default

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)

I hope you'll be successful in your project, and if this happen please post here how you fixed it.
Bye
__________________
BSP SkinMaker (v1.07) the one and only Skin Editor for BSplayer
BSP Definitions Manager (v1.02)
BS.Player's FAQ (by BSPeter) | Italian language file (v2.57 build 1051)
Reply With Quote
  #3 (permalink)  
Old 7th May 2008
Junior Member
BS.Player Newbie
 
Join Date: May 2008
Posts: 2
Rep Power: 0
MaartenKoops is an unknown quantity at this point
Default

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!
Reply With Quote
  #4 (permalink)  
Old 8th May 2008
Moderator
BS.Player Master
 
Join Date: Nov 2003
Location: Italy
Posts: 3,037
Rep Power: 28
Tizio will become famous soon enough
Default

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 ;)
__________________
BSP SkinMaker (v1.07) the one and only Skin Editor for BSplayer
BSP Definitions Manager (v1.02)
BS.Player's FAQ (by BSPeter) | Italian language file (v2.57 build 1051)
Reply With Quote
Reply

Tags
c#net, calls, pinvoke, sdk, wrapper


Posting Rules


All times are GMT +1. The time now is 11:36 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