예제 #1
0
        MainForm_Load(object sender, EventArgs e)
        {
            pathName = Application.StartupPath;

            string str = Convert.ToString(System.DateTime.Now);

            Output.Font = defFont;

            evHandler = new App_PnP_Callback(PnP_Event_Handler);

            //HID_Scan();

            //HIDCheck();

            RefreshComPortList();

            numChecked = 0;

            //checks = new CheckBox[] {Reg1Check, Reg2Check, Reg3Check, Reg4Check, Reg5Check, Reg6Check, Reg7Check, Reg8Check, Reg9Check, Reg10Check, Reg11Check, Reg12Check};

            //texts = new TextBox[] { Reg1Box, Reg2Box, Reg3Box, Reg4Box, Reg5Box, Reg6Box, Reg7Box, Reg8Box, Reg9Box, Reg10Box, Reg11Box, Reg12Box };
        }
예제 #2
0
 public void PnpNotify(App_PnP_Callback cb)
 {
     MsgWin.AppCallback = new App_PnP_Callback(cb);
 }
예제 #3
0
        public USBDeviceList(byte DeviceMask, App_PnP_Callback fnCallBack)
        {
            Items             = new ArrayList();
            hDevNotifications = new ArrayList();
            USBDriverGuids    = new ArrayList();

            EventCallBack = new App_PnP_Callback(PnP_Event_Handler);

            MsgWin.AppCallback = EventCallBack;
            AppCallBack        = fnCallBack;

            // Get the HID GUID
            PInvoke.HidD_GetHidGuid(ref HidGuid);

            // Create list of driver GUIDs for this instance
            FillDriverGuids(DeviceMask);

            USBDevice tmpDev, tmp;
            int       devs = 0;

            foreach (Guid guid in USBDriverGuids)
            {
                // tmpDev is just used for the DeviceCount functionality
                if (guid.Equals(CyConst.StorGuid))
                {
                    tmpDev = new CyUSBStorDevice(guid);
                }
                else if (guid.Equals(HidGuid))
                {
                    tmpDev = new CyHidDevice(HidGuid);
                }
                else
                {
                    tmpDev = new CyFX2Device(guid);
                }

                // DeviceCount is IO intensive. Don't use it as for loop limit
                devs = tmpDev.DeviceCount;

                for (int d = 0; d < devs; d++)
                {
                    // Create the new USBDevice objects of the correct type, based on guid
                    if (guid.Equals(CyConst.StorGuid))
                    {
                        tmp = new CyUSBStorDevice(guid);
                    }
                    else if (guid.Equals(HidGuid))
                    {
                        tmp = new CyHidDevice(HidGuid);
                    }
                    else
                    {
                        tmp = new CyFX2Device(guid);
                        if (tmp.Open((byte)d))
                        {// open handle to check device type
                            CyUSBDevice t = tmp as CyUSBDevice;
                            if (!t.CheckDeviceTypeFX3FX2())
                            {//FX3
                                tmp.Close();
                                tmp = new CyFX3Device(guid);
                            }
                            else
                            {
                                tmp.Close();
                            }
                        }
                    }

                    if (tmp.Open((byte)d))
                    {
                        Items.Add(tmp); // This creates new reference to tmp in Items
                        tmp.RegisterForPnPEvents(MsgWin.Handle);
                    }
                }

                if (guid.Equals(CyConst.StorGuid))   // We're not sure which drivers were identified, so setup PnP with both
                {
                    RegisterForPnpEvents(MsgWin.Handle, CyConst.DiskGuid);
                    RegisterForPnpEvents(MsgWin.Handle, CyConst.CdGuid);
                }
                else
                {
                    RegisterForPnpEvents(MsgWin.Handle, guid);
                }
            } // foreach guid
        }
예제 #4
0
        public USBDeviceList(byte DeviceMask, App_PnP_Callback fnCallBack)
        {
            Items = new ArrayList();
            hDevNotifications = new ArrayList();
            USBDriverGuids = new ArrayList();

            EventCallBack = new App_PnP_Callback(PnP_Event_Handler);

            MsgWin.AppCallback = EventCallBack;
            AppCallBack = fnCallBack;

            // Get the HID GUID
            PInvoke.HidD_GetHidGuid(ref HidGuid);

            // Create list of driver GUIDs for this instance
            FillDriverGuids(DeviceMask);

            USBDevice tmpDev, tmp;
            int devs = 0;

            foreach (Guid guid in USBDriverGuids)
            {
                // tmpDev is just used for the DeviceCount functionality
                if (guid.Equals(CyConst.StorGuid))
                    tmpDev = new CyUSBStorDevice(guid);
                else if (guid.Equals(HidGuid))
                    tmpDev = new CyHidDevice(HidGuid);
                else
                    tmpDev = new CyFX2Device(guid);

                // DeviceCount is IO intensive. Don't use it as for loop limit
                devs = tmpDev.DeviceCount;

                for (int d = 0; d < devs; d++)
                {
                    // Create the new USBDevice objects of the correct type, based on guid
                    if (guid.Equals(CyConst.StorGuid))
                        tmp = new CyUSBStorDevice(guid);
                    else if (guid.Equals(HidGuid))
                        tmp = new CyHidDevice(HidGuid);
                    else
                    {
                        tmp = new CyFX2Device(guid);
                        if (tmp.Open((byte)d))
                        {// open handle to check device type
                            CyUSBDevice t = tmp as CyUSBDevice;
                            if (!t.CheckDeviceTypeFX3FX2())
                            {//FX3
                                tmp.Close();
                                tmp = new CyFX3Device(guid);
                            }
                            else
                                tmp.Close();
                        }

                    }

                    if (tmp.Open((byte)d))
                    {
                        Items.Add(tmp); // This creates new reference to tmp in Items
                        tmp.RegisterForPnPEvents(MsgWin.Handle);
                    }
                }

                if (guid.Equals(CyConst.StorGuid))   // We're not sure which drivers were identified, so setup PnP with both
                {
                    RegisterForPnpEvents(MsgWin.Handle, CyConst.DiskGuid);
                    RegisterForPnpEvents(MsgWin.Handle, CyConst.CdGuid);
                }
                else
                    RegisterForPnpEvents(MsgWin.Handle, guid);

            } // foreach guid
        }
예제 #5
0
        private static MsgForm MsgWin = new MsgForm();  // Only want 1 of these.

        public void PnpNotify(App_PnP_Callback cb)
        {
            MsgWin.AppCallback = new App_PnP_Callback(cb);
        }