- const string DeviceVID_PID = "vid_04d8&pid_000c";
- [DllImport("MPUSBAPI.dll", EntryPoint = "_MPUSBGetDLLVersion")]
- public static extern int MPUSBGetDLLVersion();
- [DllImport("MPUSBAPI.dll", EntryPoint = "_MPUSBGetDeviceCount", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
- public static extern int MPUSBGetDeviceCount(
- [MarshalAs(UnmanagedType.LPStr)]StringBuilder pVID_PID);
- [DllImport("MPUSBAPI.dll", EntryPoint = "_MPUSBOpen", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
- public static extern IntPtr MPUSBOpen(int instance,
- [MarshalAs(UnmanagedType.LPStr)]StringBuilder pVID_PID,
- char[] pEP,
- int dwDir,
- int dwReserved);
- [DllImport("MPUSBAPI.dll", EntryPoint = "_MPUSBClose", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
- public static extern bool MPUSBClose(IntPtr handle);
- [DllImport("MPUSBAPI.dll", EntryPoint = "_MPUSBRead", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
- public static extern int MPUSBRead(IntPtr handle,//input
- byte[] pdata,//optput
- int dwLen, //input
- ref int Plength,//output
- int dwMilliseconds);//input
- [DllImport("MPUSBAPI.dll", EntryPoint = "_MPUSBWrite", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
- public static extern int MPUSBWrite(IntPtr handle,//input
- byte[] pData,//output
- int dwLen, //input
- ref int Plength,//output
- int dwMilliseconds);//input
- [DllImport("MPUSBAPI.dll", EntryPoint = "_MPUSBReadInt", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
- public static extern int MPUSBReadInt(IntPtr handle,//input
- UInt32[] pdata,//output
- int dwlen,//input
- Int32[] pLenght,//output
- int dwMilliseconds);//input
- IntPtr EP1INHandle, EP1OUTHandle;
C#调用VC6.0写的驱动MPUSBAPI.dll需要做一些转换才能使用