| 发表于:2007-03-08 10:43:5812楼 得分:0 |
另一个中断服务倒是可以运行并且正确的。 c++源码: typedef void ( callback * mpch375_notify_routine ) ( // 设备事件通知回调程序 ulong ieventstatus ); // 设备事件和当前状态(在下行定义): 0=设备拔出事件, 3=设备插入事件 bool winapi ch375setdevicenotify( // 设定设备事件通知程序 ulong iindex, // 指定ch375设备序号,0对应第一个设备 pchar ideviceid, // 可选参数,指向字符串,指定被监控的设备的id,字符串以\0终止 mpch375_notify_routine inotifyroutine ); // 指定设备事件回调程序,为null则取消事件通知,否则在检测到事件时调用该程序 c#: public delegate void notifycallback( ulong ieventstatus); [dllimport( "ch375dll.dll ")] private static extern bool ch375setdevicenotify( // 设定设备事件通知程序 uint iindex, // 指定ch375设备序号,0对应第一个设备 string ideviceid, // 可选参数,指向字符串,指定被监控的设备的id,字符串以\0终止 notifycallback inotifyroutine ); // 指定设备事件回调程序,为null则取消事件通知,否则在检测到事件时调用该程序 private void notify_routine(ulong ieventstatus) { if(ieventstatus==calvin.ch375.ch375_device_arrival) { this.statusbarpanel2.text= "设备已插上 "; //将设备插入消息发送到窗体进行处理 } else if(ieventstatus==calvin.ch375.ch375_device_remove) { this.statusbarpanel2.text = "设备已拔出 "; //将设备拔出消息发送到窗体进行处理 } } notifycallback mynotifycallback = new notifycallback(notify_routine); ch375.setdevicenotify(mynotifycallback)) } | | |
|