|
APlayerCaller.dll创建基本已写,创建依然失败。请求帮助。 出错图: // button1 事件是创建// 事件写在按钮下后才发现,只要创建后就会程序意外结束!- //Form1.cs 部分代码
- public delegate void fun3(int l1, int l2, int l3);//声明委托
- private void button1_Click(object sender, EventArgs e)
- {
- // new 方法并取地址,以下方同。
- fun3 DOnMessage = new fun3(OnMessage);
- POnMessage = Marshal.GetFunctionPointerForDelegate(DOnMessage);
- fun2 DOnStateChanged = new fun2(OnStateChanged);
- POnStateChanged = Marshal.GetFunctionPointerForDelegate(DOnStateChanged);
- fun0 DOnOpenSuccess = new fun0(OnOpenSuccess);
- POnOpenSuccess = Marshal.GetFunctionPointerForDelegate(DOnOpenSuccess);
- fun1 DOnSeekCompleted = new fun1(OnSeekCompleted);
- POnSeekCompleted = Marshal.GetFunctionPointerForDelegate(DOnSeekCompleted);
- fun1 DOnBuffer = new fun1(OnBuffer);
- POnBuffer = Marshal.GetFunctionPointerForDelegate(DOnBuffer);
- fun0 DOnVideoSizeChanged = new fun0(OnVideoSizeChanged);
- POnVideoSizeChanged = Marshal.GetFunctionPointerForDelegate(DOnVideoSizeChanged);
- funs1 DOnDownloadCodec = new funs1(OnDownloadCodec);
- POnDownloadCodec = Marshal.GetFunctionPointerForDelegate(DOnDownloadCodec);
- fun2 DOnEvent = new fun2(OnEvent);
- POnEvent = Marshal.GetFunctionPointerForDelegate(DOnEvent);
-
- //创建代码
- HAplayer = APlayer.APlayer.CreateAPlayer(panel1.Handle.ToInt32(), 50, 50, 200, 200, (long)POnMessage, (long)POnStateChanged, (long)POnOpenSuccess, (long)POnSeekCompleted, (long)POnBuffer, (long)POnVideoSizeChanged, (long)POnDownloadCodec, (long)POnEvent);
- MessageBox.Show("句柄是:" + HAplayer.ToString());
- //APlayer.APlayer.open(HAplayer, "F:\\视频\\C体.BD1280超清国英双语特效中英双字.mp4");
- }
- //回调方法
- void OnMessage(int l1, int l2, int l3)
- {
- //方法体
- }
- // Aplayer.cs 部分代码
- using System;
- using System.Text;
- using System.Diagnostics;
- using System.Runtime.InteropServices;
- namespace APlayer
- {
- public abstract class APlayer
- {
- [DllImportAttribute("APlayerCaller.dll", EntryPoint = "APlayer_Create")]
- public static extern int CreateAPlayer
- (
- long hParent,
- long x,
- long y,
- long nWidth,
- long nHeight,
- long OnMessage,
- long OnStateChanged,
- long OnOpenSuccess,
- long OnSeekCompleted,
- long OnBuffer,
- long OnVideoSizeChanged,
- long ondownloadcodec,
- long OnEvent
- );
- }
- }
// Debug主程序目录已经放置文件 // 求助解决,实在头疼。
|