public bool Connect() { // If we're already connected, then simply return if (fIsConnected) return fIsConnected; fIsConnected = capDriverConnect(); if (!fIsConnected) throw new Exception("VfwCaptureDevice - Connection to device failed"); // Get the driver capabilities fDriverCapabilities = new CAPDRIVERCAPS(); bool gotDriverCaps = capDriverGetCaps(ref fDriverCapabilities); // Finally allow a subclasser to do something special // upon connection. OnConnected(); capGetStatus(ref fCaptureStatus); StringBuilder sb = new StringBuilder(100); StringBuilder sbVersion = new StringBuilder(100); capDriverGetName(sb, 100); capDriverGetVersion(sbVersion, 100); fDeviceDriver = new VfwDeviceDriver(sb.ToString(), sbVersion.ToString()); return fIsConnected; }
public static extern int SendMessageW([In] IntPtr hWnd, int Msg, uint wParam, ref CAPDRIVERCAPS caps);
public bool capDriverGetCaps(ref CAPDRIVERCAPS s) { int wSize = Marshal.SizeOf(s); bool success = (1 == SendMessageW(fWindowHandle, Vfw.WM_CAP_DRIVER_GET_CAPS, (uint)wSize, ref s)); return success; }