日期:2014-05-17  浏览次数:21169 次

求助C# 开启摄像头拍照
网上找到的例子
private void OpenPreviewWindow()
        {
            int iHeight = 320;
            int iWidth = 200;
            //
            //  Open Preview window in picturebox
            //
            hHwnd = capCreateCaptureWindowA(iDevice.ToString(), (WS_VISIBLE | WS_CHILD), 0, 0, 640, 480, pictureBox1.Handle.ToInt32(), 0);
            //
            //  Connect to device
            //
            if (SendMessage(hHwnd, WM_CAP_DRIVER_CONNECT, iDevice, 0) != 1)
            {
                //
                // Set the preview scale
                //
                SendMessage(hHwnd, WM_CAP_SET_SCALE, 1, 0);
                //
                // Set the preview rate in milliseconds
                //
                SendMessage(hHwnd, WM_CAP_SET_PREVIEWRATE, 66, 0);
                //
                // Start previewing the image from the camera
                //
                SendMessage(hHwnd, WM_CAP_SET_PREVIEW, 1, 0);
                //
                //  Resize window to fit in picturebox
                //
                SetWindowPos(hHwnd, HWND_BOTTOM, 0, 0, iWidth, iHeight, (SWP_NOMOVE | SWP_NOZORDER));
            }
            else
            {
      &n