Exemplo n.º 1
0
        public void ConfigureDevice()
        {
            SoftUSBConfiguration   piConfig         = null;
            SoftUSBInterface       piInterface      = null;
            ISoftUSBConfigurations piConfigurations = null;
            ISoftUSBInterfaces     piInterfaces     = null;
            ISoftUSBEndpoints      piEndpoints      = null;

            var varIndex = Variant.VT_ERROR;

            m_piINEndpoint = new SoftUSBEndpoint();
            ConfigureINEndpoint();

            m_piOUTEndpoint = new SoftUSBEndpoint();
            ConfigureOUTEndpoint();

            piInterface = new SoftUSBInterface();
            ConfigureInterface(piInterface);

            //Add the Endpoints to the endpoint collection
            piEndpoints = piInterface.Endpoints;
            piEndpoints.Add(m_piINEndpoint, varIndex);
            piEndpoints.Add(m_piOUTEndpoint, varIndex + 1);

            piConfig = new SoftUSBConfiguration();
            ConfigureConfig(piConfig);

            piInterfaces = piConfig.Interfaces;
            piInterfaces.Add(piInterface, varIndex);

            piConfigurations = m_piSoftUSBDevice.Configurations;
            piConfigurations.Add(piConfig, varIndex);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Setup the connection point to the OUT Endpoint.It validates that
        /// the punkObject supports IConnectionPointContainer then finds the
        /// correct connection point and attaches this object as the event sink.
        /// </summary>
        /// <param name="usbEndpoint"></param>
        /// <param name="iidConnectionPoint"></param>
        public void SetupConnectionPoint(SoftUSBEndpoint usbEndpoint, ref Guid iidConnectionPoint)
        {
            IConnectionPointContainer piConnectionPointContainer = null;

            if (m_piConnectionPoint != null)
            {
                ReleaseConnectionPoint();
            }
            Guid   guid     = new Guid("B196B284-BAB4-101A-B69C-00AA00341D07");
            Type   type     = Type.GetTypeFromCLSID(guid);
            object comObj   = Activator.CreateInstance(type);
            IntPtr punkSink = Marshal.GetIUnknownForObject(comObj);
            IntPtr pInterface;

            Marshal.QueryInterface(punkSink, ref guid, out pInterface);

            piConnectionPointContainer = (IConnectionPointContainer)comObj;

            piConnectionPointContainer.FindConnectionPoint(iidConnectionPoint, out m_piConnectionPoint);

            m_piConnectionPoint.Advise(punkSink, out m_dwConnectionCookie);
        }