Click here to Skip to main content
16,015,481 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
See more:
Hi,
In C#, can we write a program which will do the following thing?
Whenever some external device is connected with it through USB port:
i.I can detect the device type[webcam,card reader etc.]
ii.Search the existence of corresponding driver s/w in the local m/c,if found,execute[run] automatically.
There are other additional functionalists as well,but for the beginning,can we implement the above two scenarios?

Thanks,
Avishek
Posted

I would start reading up from here[^] (or many other[^] resources on Google).
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 8-Feb-11 16:43pm    
Very good, my 5
--SA
Adding to Manas's answer:

You will most likely need to P/Invoke RegisterDeviceNotification and related APIs.

See http://msdn.microsoft.com/en-us/library/aa363431(v=vs.85).aspx[^]
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 8-Feb-11 16:43pm    
Sure, my 5,
--SA
absolutely dear,
using system.io;

//Get all drives enumeration using
DriveInfo di[]= DriveInfo.GetDrives();
foreach(DriveInfo divinfo in fi)
{
         If(divinfo.IsReady)
            {
                  Console.writeline(divinfo.DriveType);
            }
else
Console.Writeline("Device not Ready");

}
// To detect devices automatically
use a timer control and call a method in every 5 or 10 second that include this for loop
 
Share this answer
 
v2
Hi ,
i want code in C#. how to detect the usb device .if conneted USb .In which port USb pluged
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900