示例#1
0
        /// <summary>
        /// Binds the class instance methods to the dll functions.
        /// </summary>
        /// <param name="hDll">A dll to bind to.</param>
        private void BindToDll(IntPtr hDll)
        {
            IntPtr pProcPtr = GetProcAddress(hDll, "EnumVideoInputDevices");

            this._enumVideoInputDevices =
                (EnumVideoInputDevicesDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(EnumVideoInputDevicesDelegate));

            pProcPtr = GetProcAddress(hDll, "BuildCaptureGraph");
            this._buildCaptureGraph =
                (BuildCaptureGraphDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(BuildCaptureGraphDelegate));

            pProcPtr = GetProcAddress(hDll, "AddRenderFilter");
            this._addRenderFilter =
                (AddRenderFilterDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(AddRenderFilterDelegate));

            pProcPtr = GetProcAddress(hDll, "AddCaptureFilter");
            this._addCaptureFilter =
                (AddCaptureFilterDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(AddCaptureFilterDelegate));

            pProcPtr = GetProcAddress(hDll, "ResetCaptureGraph");
            this._resetCaptureGraph =
                (ResetCaptureGraphDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(ResetCaptureGraphDelegate));

            pProcPtr    = GetProcAddress(hDll, "Start");
            this._start = (StartDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(StartDelegate));

            pProcPtr = GetProcAddress(hDll, "GetCurrentImage");
            this._getCurrentImage =
                (GetCurrentImageDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(GetCurrentImageDelegate));

            pProcPtr           = GetProcAddress(hDll, "GetVideoSize");
            this._getVideoSize =
                (GetVideoSizeDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(GetVideoSizeDelegate));

            pProcPtr   = GetProcAddress(hDll, "Stop");
            this._stop = (StopDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(StopDelegate));

            pProcPtr = GetProcAddress(hDll, "DestroyCaptureGraph");
            this._destroyCaptureGraph =
                (DestroyCaptureGraphDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(DestroyCaptureGraphDelegate));
        }
示例#2
0
        /// <summary>
        /// Binds the class instance methods to the dll functions.
        /// </summary>
        /// <param name="hDll">A dll to bind to.</param>
        private void BindToDll(IntPtr hDll)
        {
            IntPtr pProcPtr = GetProcAddress(hDll, "EnumVideoInputDevices");
            _enumVideoInputDevices =
                (EnumVideoInputDevicesDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(EnumVideoInputDevicesDelegate));

            pProcPtr = GetProcAddress(hDll, "BuildCaptureGraph");
            _buildCaptureGraph =
                (BuildCaptureGraphDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(BuildCaptureGraphDelegate));

            pProcPtr = GetProcAddress(hDll, "AddRenderFilter");
            _addRenderFilter =
                (AddRenderFilterDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(AddRenderFilterDelegate));

            pProcPtr = GetProcAddress(hDll, "AddCaptureFilter");
            _addCaptureFilter =
                (AddCaptureFilterDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(AddCaptureFilterDelegate));

            pProcPtr = GetProcAddress(hDll, "ResetCaptureGraph");
            _resetCaptureGraph =
                (ResetCaptureGraphDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(ResetCaptureGraphDelegate));

            pProcPtr = GetProcAddress(hDll, "Start");
            _start = (StartDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(StartDelegate));

            pProcPtr = GetProcAddress(hDll, "GetCurrentImage");
            _getCurrentImage =
                (GetCurrentImageDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(GetCurrentImageDelegate));

            pProcPtr = GetProcAddress(hDll, "GetVideoSize");
            _getVideoSize =
                (GetVideoSizeDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(GetVideoSizeDelegate));

            pProcPtr = GetProcAddress(hDll, "Stop");
            _stop = (StopDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(StopDelegate));

            pProcPtr = GetProcAddress(hDll, "DestroyCaptureGraph");
            _destroyCaptureGraph =
                (DestroyCaptureGraphDelegate)Marshal.GetDelegateForFunctionPointer(pProcPtr, typeof(DestroyCaptureGraphDelegate));
        }