Click here to Skip to main content
15,890,609 members
Home / Discussions / C#
   

C#

 
GeneralRe: Dictionary Error? (or User Error! more likely) Pin
glennPattonWork34-Jul-12 23:35
professionalglennPattonWork34-Jul-12 23:35 
GeneralRe: Dictionary Error? (or User Error! more likely) Pin
Pete O'Hanlon4-Jul-12 23:43
mvePete O'Hanlon4-Jul-12 23:43 
GeneralRe: Dictionary Error? (or User Error! more likely) Pin
glennPattonWork35-Jul-12 0:04
professionalglennPattonWork35-Jul-12 0:04 
GeneralRe: Dictionary Error? (or User Error! more likely) Pin
Pete O'Hanlon5-Jul-12 0:11
mvePete O'Hanlon5-Jul-12 0:11 
GeneralRe: Dictionary Error? (or User Error! more likely) Pin
glennPattonWork35-Jul-12 0:30
professionalglennPattonWork35-Jul-12 0:30 
GeneralRe: Dictionary Error? (or User Error! more likely) Pin
Pete O'Hanlon5-Jul-12 0:32
mvePete O'Hanlon5-Jul-12 0:32 
GeneralRe: Dictionary Error? (or User Error! more likely) Pin
glennPattonWork35-Jul-12 0:45
professionalglennPattonWork35-Jul-12 0:45 
GeneralRe: Dictionary Error? (or User Error! more likely) Pin
Pete O'Hanlon5-Jul-12 0:54
mvePete O'Hanlon5-Jul-12 0:54 
Try this to retrieve a list of all the drivers and display them on the console.
C#
class Program
{
    static void Main(string[] args)
    {
        List<SignedDriver> drivers = GetDriverInfo();
        foreach (SignedDriver driver in drivers)
        {
          Console.WriteLine("Driver name: {0} - Version : [1} - Date {2}", 
             driver.DeviceName, driver.DriverVersion, driver.DriverDate);
        }
        Console.WriteLine("Finished processing");
        Console.ReadKey();
    }
    public class SignedDriver
    {
        public string DriverVersion;
        public string DeviceName;
        // Note that this is not really a date.
        // The format is a touch weird.
        public string DriverDate;
    }
    public static List<SignedDriver> GetDriverInfo()
    {
        List<SignedDriver> drivers = new List<SignedDriver>();
        SelectQuery query = new SelectQuery("Win32_PnPSignedDriver");
        ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);
        foreach (ManagementObject manageObject in searcher.Get())
        {
            object driverVer = manageObject.Properties["DriverVersion"].Value;
            object deviceName = manageObject.Properties["DeviceName"].Value;
            object driverDate = manageObject.Properties["DriverDate"].Value;
            if (deviceName != null)
            {
                SignedDriver driver = new SignedDriver();
                driver.DeviceName = deviceName.ToString();
                driver.DriverDate = driverDate.ToString();
                driver.DriverVersion = driverVer.ToString();
                drivers.Add(driver);
            }
        }
        return drivers;
    }
}
And to answer your question, it's nearly mid day here in the UK.

*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

"Mind bleach! Send me mind bleach!" - Nagy Vilmos


CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

GeneralRe: Dictionary Error? (or User Error! more likely) Pin
glennPattonWork35-Jul-12 1:35
professionalglennPattonWork35-Jul-12 1:35 
GeneralRe: Dictionary Error? (or User Error! more likely) Pin
Pete O'Hanlon5-Jul-12 1:53
mvePete O'Hanlon5-Jul-12 1:53 
GeneralRe: Dictionary Error? (or User Error! more likely) Pin
glennPattonWork35-Jul-12 2:24
professionalglennPattonWork35-Jul-12 2:24 
GeneralRe: Dictionary Error? (or User Error! more likely) Pin
glennPattonWork35-Jul-12 4:46
professionalglennPattonWork35-Jul-12 4:46 
GeneralRe: Dictionary Error? (or User Error! more likely) Pin
Pete O'Hanlon5-Jul-12 5:33
mvePete O'Hanlon5-Jul-12 5:33 
GeneralRe: Dictionary Error? (or User Error! more likely) Pin
glennPattonWork35-Jul-12 5:41
professionalglennPattonWork35-Jul-12 5:41 
GeneralRe: Dictionary Error? (or User Error! more likely) Pin
Pete O'Hanlon5-Jul-12 5:49
mvePete O'Hanlon5-Jul-12 5:49 
GeneralRe: Dictionary Error? (or User Error! more likely) Pin
glennPattonWork35-Jul-12 5:56
professionalglennPattonWork35-Jul-12 5:56 
GeneralRe: Dictionary Error? (or User Error! more likely) Pin
Pete O'Hanlon5-Jul-12 6:46
mvePete O'Hanlon5-Jul-12 6:46 
Questionhow to bind datasource to treeview control Pin
mahendraprabu.m4-Jul-12 4:48
mahendraprabu.m4-Jul-12 4:48 
QuestionRe: how to bind datasource to treeview control Pin
Richard MacCutchan4-Jul-12 4:58
mveRichard MacCutchan4-Jul-12 4:58 
QuestionRe: how to bind datasource to treeview control Pin
Pete O'Hanlon4-Jul-12 6:45
mvePete O'Hanlon4-Jul-12 6:45 
Generali m getting an error while using array, please help me Pin
somasekhara7774-Jul-12 1:56
somasekhara7774-Jul-12 1:56 
SuggestionRe: i m getting an error while using array, please help me Pin
Eddy Vluggen4-Jul-12 2:05
professionalEddy Vluggen4-Jul-12 2:05 
AnswerRe: i m getting an error while using array, please help me Pin
markovl4-Jul-12 2:16
markovl4-Jul-12 2:16 
AnswerRe: i m getting an error while using array, please help me Pin
Pete O'Hanlon4-Jul-12 2:16
mvePete O'Hanlon4-Jul-12 2:16 
GeneralRe: i m getting an error while using array, please help me Pin
markovl4-Jul-12 2:21
markovl4-Jul-12 2:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.