MVCAPI.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. using System.Runtime.InteropServices;
  2. using System.Text;
  3. namespace ivf_tl_CameraHelper
  4. {
  5. public class MVCAPI
  6. {
  7. public delegate void LPMV_CALLBACK2(IntPtr lpParam, IntPtr lpUser);
  8. public const short ResSuccess = 0x0000;
  9. public const short ResNullHandleErr = 0x0001;
  10. public const short ResNullPointerErr = 0x0002;
  11. public const short ResFileOpenErr = 0x0003;
  12. public const short ResNoDeviceErr = 0x0004;
  13. public const short ResInvalidParameterErr = 0x0005;
  14. public const short ResOutOfMemoryErr = 0x0006;
  15. public const short ResNoPreviewRunningErr = 0x0007;
  16. public const short ResOSVersionErr = 0x0008;
  17. public const short ResUsbNotAvailableErr = 0x0009;
  18. public const short ResNotSupportedErr = 0x000a;
  19. public const short ResNoSerialString = 0x000b;
  20. public const short ResVerificationErr = 0x000c;
  21. public const short ResUnknowErr = 0x00ff;
  22. public const int WS_CHILD = 0x40000000;
  23. public const int WS_VISIBLE = 0x10000000;
  24. //public static uint WS_CHILD = 1073741824u;
  25. //public static uint WS_VISIBLE = 268435456u;
  26. [DllImport(@"DependFile\ccd\mvcapi.dll")]
  27. public static extern Int32 MV_Usb2Init(String pFilterName, out int index, ref CapInfoStruct pCapInfo, out IntPtr hImager);
  28. [DllImport(@"DependFile\ccd\mvcapi.dll")]
  29. public static extern Int32 MV_Usb2GetSerial(IntPtr hImager, StringBuilder number);
  30. /// <summary>
  31. /// 卸载相机,成功返回0
  32. /// </summary>
  33. /// <param name="hImager"></param>
  34. /// <returns></returns>
  35. [DllImport(@"DependFile\ccd\mvcapi.dll")]
  36. public static extern Int32 MV_Usb2Uninit(ref IntPtr hImager);
  37. [DllImport(@"DependFile\ccd\mvcapi.dll")]
  38. public static extern Int32 MV_Usb2Start(IntPtr hImager, String tilte, uint style, int x, int y, int width, int height, IntPtr parent, uint nId, int ViewDataThreadPriority, int ViewDrawThreadPriority);
  39. [DllImport(@"DependFile\ccd\mvcapi.dll")]
  40. public static extern Int32 MV_Usb2StartCapture(IntPtr hImager, bool bCapture);
  41. [DllImport(@"DependFile\ccd\mvcapi.dll")]
  42. public static extern Int32 MV_Usb2Stop(IntPtr hImager);
  43. [DllImport(@"DependFile\ccd\mvcapi.dll")]
  44. public static extern Int32 MV_Usb2PausePreview(IntPtr hImager, bool bPause);
  45. [DllImport(@"DependFile\ccd\mvcapi.dll")]
  46. public static extern Int32 MV_Usb2GetFrameRate(IntPtr hImager, out float nRate);
  47. /**************************************************/
  48. [DllImport(@"DependFile\ccd\mvcapi.dll")]
  49. public static extern Int32 MV_Usb2SetOpMode(IntPtr hImager, byte nMode, bool bStrobe);
  50. [DllImport(@"DependFile\ccd\mvcapi.dll")]
  51. public static extern Int32 MV_Usb2SetPartOfCapInfo(IntPtr hImager, ref CapInfoStruct pCapInfo);
  52. [DllImport(@"DependFile\ccd\mvcapi.dll")]
  53. public static extern Int32 MV_Usb2GetRgbData(IntPtr hImager, ref CapInfoStruct pCapInfo, IntPtr pDest);
  54. [DllImport(@"DependFile\ccd\mvcapi.dll")]
  55. public static extern Int32 MV_Usb2GetRawData(IntPtr hImager, ref CapInfoStruct pCapInfo);
  56. [DllImport(@"DependFile\ccd\mvcapi.dll")]
  57. public static extern Int32 MV_Usb2ConvertRawToRgb(IntPtr hImager, IntPtr pSrc, int width, int height, IntPtr pDest);
  58. [DllImport(@"DependFile\ccd\mvcapi.dll")]
  59. public static extern Int32 MV_Usb2SaveFrameAsBmp(IntPtr hImager, ref CapInfoStruct pCapInfo, IntPtr pDest, string strname);
  60. [DllImport(@"DependFile\ccd\mvcapi.dll")]
  61. public static extern Int32 MV_Usb2SetMaskCallBack(IntPtr hImager, LPMV_CALLBACK2 MaskCallBackFunction, IntPtr lpUser);
  62. [DllImport(@"DependFile\ccd\mvcapi.dll")]
  63. public static extern Int32 MV_Usb2SetFrameCallBack(IntPtr hImager, LPMV_CALLBACK2 CALLBACKFUNCT, IntPtr lpUser);
  64. [DllImport(@"DependFile\ccd\mvcapi.dll")]
  65. public static extern Int32 MV_Usb2SetMask(IntPtr hImager, bool bMask);
  66. [DllImport(@"DependFile\ccd\MVCAPI.dll")]
  67. public static extern int MV_Usb2SavePausedFrameAsBmp(IntPtr hImager, string fileName);
  68. [DllImport(@"DependFile\ccd\MVCAPI.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
  69. public static extern int MV_Usb2GetPausedRgbData(IntPtr intptr_device, IntPtr rgbdata);
  70. [DllImport(@"DependFile\ccd\mvavi.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
  71. public static extern void MV_AVIFileInit(uint filetype, short framerate);
  72. [DllImport(@"DependFile\ccd\mvavi.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
  73. public static extern void MV_AVIFileFini();
  74. [DllImport(@"DependFile\ccd\MVCAPI.dll")]
  75. public static extern Int32 MV_Usb2GetNumberDevicesEX(out int devnum);
  76. }
  77. }