Example #1
0
        public static string UISelectMatchingHardwareID(PNPDriverDirectory driverDirectory, string architectureIdentifier, int minorOSVersion, int productType)
        {
            List <KeyValuePair <string, string> > devices = driverDirectory.ListDevices(architectureIdentifier, minorOSVersion, productType);

            Console.WriteLine();
            Console.WriteLine("Looking for matching device drivers in directory '{0}':", driverDirectory.Path);
            return(UISelectMatchingHardwareID(devices));
        }
        public static List <string> DetectMatchingExportedHardware(string path, PNPDriverDirectory driverDirectory, string architectureIdentifier, int minorOSVersion, int productType)
        {
            List <KeyValuePair <string, string> > devices = driverDirectory.ListDevices(architectureIdentifier, minorOSVersion, productType);
            List <string> driverHardwareID = new List <string>();

            foreach (KeyValuePair <string, string> device in devices)
            {
                driverHardwareID.Add(device.Key);
            }
            return(DetectMatchingExportedHardware(path, driverHardwareID));
        }
Example #3
0
        public static string UISelectHardwareID(PNPDriverDirectory pnpDriverDirectory, WindowsInstallation installation, bool useLocalHardwareConfig, string enumExportPath)
        {
            string hardwareID;
            bool   containsRootDevices = pnpDriverDirectory.ContainsRootDevices(installation.ArchitectureIdentifier, installation.MinorOSVersion, installation.ProductType);

            // We should not use our detection mechanism if a driver directory contains a root device.
            if (!containsRootDevices && (useLocalHardwareConfig || enumExportPath != String.Empty))
            {
                List <string> matchingHardwareIDs;
                if (useLocalHardwareConfig)
                {
                    matchingHardwareIDs = PNPLocalHardwareDetector.DetectMatchingLocalHardware(pnpDriverDirectory, installation.ArchitectureIdentifier, installation.MinorOSVersion, installation.ProductType);
                }
                else
                {
                    matchingHardwareIDs = PNPExportedHardwareDetector.DetectMatchingExportedHardware(enumExportPath, pnpDriverDirectory, installation.ArchitectureIdentifier, installation.MinorOSVersion, installation.ProductType);
                }
                List <KeyValuePair <string, string> > devices = pnpDriverDirectory.ListDevices(installation.ArchitectureIdentifier, installation.MinorOSVersion, installation.ProductType);
                // We now have a list of hardware IDs that matches (some of) our devices, let's found out which of the devices match
                List <KeyValuePair <string, string> > matchingDevices = new List <KeyValuePair <string, string> >();
                foreach (KeyValuePair <string, string> device in devices)
                {
                    if (matchingHardwareIDs.Contains(device.Key))
                    {
                        matchingDevices.Add(device);
                    }
                }
                Console.WriteLine();
                Console.WriteLine("Looking for matching device drivers in directory '{0}':", pnpDriverDirectory.Path);
                hardwareID = UISelectMatchingHardwareID(matchingDevices);
            }
            else
            {
                hardwareID = UISelectMatchingHardwareID(pnpDriverDirectory, installation.ArchitectureIdentifier, installation.MinorOSVersion, installation.ProductType);
            }

            return(hardwareID);
        }