Ports
May 19, 2013, 03:51:52 pm
Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News
: SMF - Just Installed!
Home
Help
Search
Login
Register
Welcome to the PORTS Forum. Please post your questions, answers, and comments relating to USB and other hardware interfaces in the appropriate forums below. - Jan
Ports
>
General Category
>
Serial Ports
>
Problem need to check for a Driver....
Pages: [
1
]
« previous
next »
Print
Author
Topic: Problem need to check for a Driver.... (Read 1076 times)
GlennP
Frequent Contributor
Posts: 126
Problem need to check for a Driver....
«
on:
June 27, 2012, 08: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
Logged
HDowns
Member
Posts: 13
Re: Problem need to check for a Driver....
«
Reply #1 on:
July 04, 2012, 11:52:33 pm »
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
Logged
GlennP
Frequent Contributor
Posts: 126
Re: Problem need to check for a Driver....
«
Reply #2 on:
July 06, 2012, 03:37:15 am »
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
Logged
Pages: [
1
]
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
General Category
-----------------------------
=> USB
=> Serial Ports
=> Embedded Ethernet
=> Parallel Port
=> Other Interfaces
=> General Discussion
Loading...