PORTS Forum
Ports and Interfaces => Serial Ports => Topic started by: GlennP on June 27, 2012, 09:30:01 am
-
Hi All,
I am trying to find a method of detecting whether or not the Microchip USB to Serial Port driver is installed. I have the below code
private void button1_Click(object sender, EventArgs e)
{
// MessageBox.Show("hello!");
ServiceController[] scDevices = ServiceController.GetDevices();
MessageBox.Show("Device driver services on the local computer");
foreach (ServiceController scTemp in scDevices)
{
rtbDrivers.Text += ("\n" + scTemp.ServiceType+","+scTemp.ServiceName+","+ scTemp.DisplayName);
}
}
this will list the drivers installed on the system which is the driver I am looking for HELP? I will also ask this at Microchip if I can figure out there site.
GlennP
-
DevView.exe utility can help you, but it is too old and does not work in Vista or Windows 7.
http://www.oneysoft.com/devview.htm
-
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