This is what I get for installed software. I downloaded the Sixnet driver package and installed it. Now I want to detect if it has actually installed the drivers with the code below:
var searcher = new ManagementObjectSearcher("SELECT * FROM Win32_PnPSignedDriver");
foreach (ManagementObject obj in searcher.Get())
{
//Looking for Sixnet USB Ethernet/RNDIS Gadget. Only try on objects that actually have a description.
if (obj.GetPropertyValue("Description") != null)
{
try
{
if (obj.GetPropertyValue("Description").ToString().Contains("Sixnet USB Ethernet"))
{
return true;
}
}
catch (Exception e)
{
}
}
}
return false;
I am pretty sure it was returning true earlier today but now I cannot get this block to work, it does not detect the driver.
Lower down in the code I connect to the NIC and that works but it was my understanding that it would only connect to the NIC if the driver was actually installed because the default driver does not work.
Below is my network connections and I can see the modem as Network 5 - the one with Sixnet in the name. Why does my code not want to show that the drivers are installed? I want to run the software to first check if the drivers were installed and then if I can connect to the Sixnet modem via a USB cable. Thank you
Edit: Ok, I changed obj.GetPropertyValue("Description") to obj.GetPropertyValue("Devicename") and it did not work immediately so I moved on to other work and 10 minutes later it worked? How do I refresh the WMI database?
Edit #2:
private bool Check_Drivers()
{
var searcher = new ManagementObjectSearcher("SELECT * FROM Win32_PnPSignedDriver where DeviceName LIKE '%Sixnet USB%'");
if (searcher.Get().Count > 0)
{
searcher = null;
return true;
}
searcher = null;
return false;
}
I changed my whole method to the code above. The searcher = null; was my attempt to make sure every call to this method reloads the management object.