c#调用RAPI的连接判断
在c#中调用rapi来完成windows ce的文件操作。详细参见:http://blog.csdn.net/jarvisj/archive/2005/06/05/387902.aspx详细api文档(msdn英文):http://msdn.microsoft.com/en-us/library/aa458022.aspx但是如果用 CeRapiInit来判断链接有一个问题:这个函数的运行过程是开始判断是否连接了设备,如果没有设备,这个进程将一直挂着,直到插上了设备才继续执行,这样就不能马上给出判断,所以可以采用CeRapiInitEx函数。CeRapiInit和CeRapiInitEx的区别:前者是将进程一直挂着,等待设备的插入,而后者是即刻判断。主要讲解CeRapiInitEx的使用://接口声明public static extern void CeRapiInitEx(ref RAPIINIT pRapiInit);//自定义返回类型结构public struct RAPIINIT{public int cbsize;public IntPtr heRapiInit;public UInt32 hrRapiInit;};//函数使用RAPIINIT r = new RAPIINIT();r.cbsize = Marshal.SizeOf(r);CeRapiInitEx(ref r);//r.hrRapiInit==0 判断连接成功
页:
[1]