Hi All,
Serial Port guy who does usually mess with USB trying to find USB drivers got a solution, thought I would share it out of relief and possibly cause I am not alone in needing it
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) && (driverDate != null) && (driverVer != null))
{
SignedDriver driver = new SignedDriver();
driver.DeviceName = deviceName.ToString();
if (driver.DriverDate != null)
driver.DriverDate = driverDate.ToString();
if (driver.DriverVersion != null)
driver.DriverVersion = driverVer.ToString();
driver.DeviceName = deviceName.ToString();
driver.DriverDate = driverDate.ToString();
driver.DriverVersion = driverVer.ToString();
drivers.Add(driver);
}
}
return drivers;
}
The data can be got at via it fills up a list box
private void button5_Click(object sender, EventArgs e)
{
List<SignedDriver> drivers = GetDriverInfo();
foreach (SignedDriver driver in drivers)
listBox1.Items.Add(driver.DeviceName+","+driver.DriverDate+","+driver.DriverVersion);
}
the actual driver is
int index = -1;
//USB Serial Converter,20120410000000.******+***,2.8.24.0
index = listBox1.FindString("USB Serial Converter,20120410000000.******+***,2.8.24.0");
if (index == -1)
{
MessageBox.Show(" Driver Not Found ");
}else
MessageBox.Show("index = " + index.ToString()+","+listBox1.Items[20].ToString());
Which I found from device manger (which serial port appeared when device was attached) by the revision number in device manger.
Hope that helps somebody!
Glenn