/// <summary>
 /// 关闭视频设备
 /// </summary>
 public void CloseWebcam()
 {
     try
     {
         VideoAPI.SendMessage(lwndC, VideoAPI.WM_CAP_DRIVER_DISCONNECT, 0, 0);
     }
     catch (Exception e)
     {
         mErrorMsg = "关闭摄像头出错,原因:" + e.Message;
         throw new Exception(mErrorMsg);
     }
 }
 ///   <summary>
 ///   拍照
 ///   </summary>
 ///   <param   name="path">要保存jpeg文件的路径</param>
 public void GrabImage(IntPtr hWndC, string path)
 {
     try
     {
         IntPtr hBmp = Marshal.StringToHGlobalAnsi(path);
         VideoAPI.SendMessage(lwndC, VideoAPI.WM_CAP_SAVEDIB, 0, hBmp.ToInt32());
     }
     catch (Exception e)
     {
         mErrorMsg = "抓取图像" + path + "失败+原因:" + e.Message;
         throw new Exception(mErrorMsg);
     }
 }
 /// <summary>
 /// 打开视频设备
 /// </summary>
 public void StartWebCam()
 {
     byte[] lpszName = new byte[100];
     byte[] lpszVer  = new byte[100];
     try
     {
         VideoAPI.capGetDriverDescriptionA(0, lpszName, 100, lpszVer, 100);
         this.lwndC = VideoAPI.capCreateCaptureWindowA(lpszName, VideoAPI.WS_CHILD | VideoAPI.WS_VISIBLE, 0, 0, mWidth, mHeight, mControlPtr, 0);
         if (VideoAPI.SendMessage(lwndC, VideoAPI.WM_CAP_DRIVER_CONNECT, 0, 0))
         {
             VideoAPI.SendMessage(lwndC, VideoAPI.WM_CAP_SET_PREVIEWRATE, 100, 0);
             VideoAPI.SendMessage(lwndC, VideoAPI.WM_CAP_SET_PREVIEW, true, 0);
         }
         else
         {
             mErrorMsg = "连接摄像头失败[1]请检查USB是否正确安装.[2]是否正确安装驱动";
         }
     }
     catch (Exception e)
     {
         mErrorMsg = "打开摄像头出错,原因:" + e.Message;
         throw new Exception(mErrorMsg);
     }
 }