使用C#从/向bsplayer发送/接收命令 [英] send/receive commands from/to bsplayer using c#

查看:114
本文介绍了使用C#从/向bsplayer发送/接收命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用c#环境从bsplayer发送/接收命令.
我进入了c:\ Program Files \ Webteh \ BSplayerPro \ sdk \文件夹,发现其中有2个文件:bsp.h和bsp.pas.我打开了bsp.h文件(是旧的c/c ++语言的标头).我在这里阅读了说明:

I want to send/receive commands from/to bsplayer, using c# environment.
I went in c:\Program Files\Webteh\BSplayerPro\sdk\ folder and I find there 2 files: bsp.h and bsp.pas. I opened the bsp.h file (is a header for old c/c++ language). I read the instructions there:

//To get BSPlayer window handle use:
//bsp_hand=FindWindow("BSPlayer",NULL);
// then you can send messages, for ex. to get current version:
// bsp_ver = SendMessage(bsp_hand,WM_BSP_CMD,BSP_GETVERSION,0);




在我的C#程序中,我写道:




In my c# program, I wrote:

//Im not sure is correct but im trying
 p_BsPlayer.Handle.ToString(@"bsp_hand=FindWindow(""BSPlayer"",NULL);");



现在是第二部分...



now for the second part...

//how can I write the next line?
//  then you can send messages, for ex. to get current version:
//   bsp_ver = SendMessage(bsp_hand,WM_BSP_CMD,BSP_GETVERSION,0);  <<<this one





thanks.

推荐答案

//Im not sure is correct but im trying
 p_BsPlayer.Handle.ToString(@"bsp_hand=FindWindow(""BSPlayer"",NULL);");


这句话没什么意思,您期望什么?为了使用FindWindow()功能,您将需要按此处所述使用P/Invoke [ ^ ].另外,您也可以用纯C或C ++编写代码,这会容易得多(假设您了解该语言).


This statement means nothing, what were you expecting? In order to use the FindWindow() function you will need to use P/Invoke as described here[^]. Alternatively you could write your code in pure C or C++ which would be considerably easier (assuming you know the language).


首先,您应该打开Bsplayer窗口.
使用BSplayer打开电影的解决方案(尽管它在C/C ++中可能很有用.)

无效的Film()
{
STARTUPINFO si;
PROCESS_INFORMATION pi;

ZeroMemory(&si,sizeof(si));
si.cb = sizeof(si);
ZeroMemory(&pi,sizeof(pi));

wchar_t path_to_bsplayer [512] = L";
wchar_t command [512] = L"/c"; //在"/c"之后,例如可以将影片的路径写入以打开
//启动子进程.
CreateProcess(path_to_bsplayer,//BSplayer的模块名称路径
L"/c",//Parancs
NULL,//进程句柄不可继承
NULL,//线程句柄不可继承
FALSE,//将句柄继承设置为FALSE
0,//没有创建标志
NULL,//使用父级的环境块
NULL,//使用父级的起始目录
&si,//指向STARTUPINFO结构的指针
&pi); //指向PROCESS_INFORMATION结构的指针

//等待子进程退出.
//WaitForSingleObject(pi.hProcess,INFINITE);
//关闭进程和线程句柄.
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
}
First, you should open the Bsplayer Window.
The solution for opening a film with BSplayer (it''s in C/C++ though, could be useful.)

void Film()
{
STARTUPINFO si;
PROCESS_INFORMATION pi;

ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );

wchar_t path_to_bsplayer[512]=L"";
wchar_t command[512]=L"/c "; //after "/c " e.g can write path to a film to open
// Start the child process.
CreateProcess( path_to_bsplayer, // module name path to BSplayer
L"/c ", // Parancs
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
FALSE, // Set handle inheritance to FALSE
0, // No creation flags
NULL, // Use parent''s environment block
NULL, // Use parent''s starting directory
&si, // Pointer to STARTUPINFO structure
&pi ); // Pointer to PROCESS_INFORMATION structure

// Wait until child process exits.
//WaitForSingleObject( pi.hProcess, INFINITE );
// Close process and thread handles.
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
}


这篇关于使用C#从/向bsplayer发送/接收命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆