示例#1
0
        public List <DriverStoreEntry> EnumeratePackages()
        {
            List <DriverStoreEntry> driverStoreEntries = new List <DriverStoreEntry>();
            string output = "";

            if (PnpUtilHelper(PnpUtilOptions.Enumerate, null, ref output))
            {
                // Parse the output
                driverStoreEntries = ParsePnpUtilEnumerateResult(output);

                DriverStoreRepository repository = new DriverStoreRepository();

                for (int i = 0; i < driverStoreEntries.Count; i++)
                {
                    DriverStoreEntry driverStoreEntry = driverStoreEntries[i];
                    if (driverStoreEntry.DriverPublishedName != null)
                    {
                        repository.FindInfInfo(driverStoreEntry.DriverPublishedName, out driverStoreEntry.DriverInfName, out driverStoreEntry.DriverSize);
                    }
                    driverStoreEntries[i] = driverStoreEntry;
                }
            }

            return(driverStoreEntries);
        }
示例#2
0
        public List <DriverStoreEntry> EnumeratePackages()
        {
            List <DriverStoreEntry> driverStoreEntries = new List <DriverStoreEntry>();
            string output = "";

            if (PnpUtilHelper(PnpUtilOption.Enumerate, null, ref output))
            {
                // Parse the output
                driverStoreEntries = ParsePnpUtilEnumerateResult(output);

                DriverStoreRepository repository = new DriverStoreRepository();

                List <DeviceDriverInfo> driverInfo = ConfigManager.GetDeviceDriverInfo();

                for (int i = 0; i < driverStoreEntries.Count; i++)
                {
                    DriverStoreEntry driverStoreEntry = driverStoreEntries[i];

                    if (!string.IsNullOrEmpty(driverStoreEntry.DriverPublishedName))
                    {
                        repository.FindInfInfo(
                            driverStoreEntry.DriverPublishedName,
                            out string driverInfName,
                            out string driverFolderLocation,
                            out long driverSize);

                        driverStoreEntry.DriverInfName        = driverInfName;
                        driverStoreEntry.DriverFolderLocation = driverFolderLocation;
                        driverStoreEntry.DriverSize           = driverSize;

                        var deviceInfo = driverInfo.OrderByDescending(d => d.IsPresent).FirstOrDefault(e => string.Equals(
                                                                                                           Path.GetFileName(e.DriverInf),
                                                                                                           driverStoreEntry.DriverPublishedName,
                                                                                                           StringComparison.OrdinalIgnoreCase));

                        driverStoreEntry.DeviceName    = deviceInfo?.DeviceName;
                        driverStoreEntry.DevicePresent = deviceInfo?.IsPresent;

                        driverStoreEntries[i] = driverStoreEntry;
                    }
                }
            }

            return(driverStoreEntries);
        }