Solved

is the usb inserted and the driver loaded, delphi programming

Posted on 2011-03-08
4
503 Views
Last Modified: 2012-05-11
a USB device is inserted into usb port on WinXP computer. in reponse the operating system loads the necessary drivers.

My program is communicating to this usb device using the loaded driver. My problem is to determine if the device has been inserted into the USB and/or if the driver is loaded by the operating system.

If I just go ahead and access the driver before it is initialized I get an access violation. also I need to find a mechanism to detect if the user has removed the device again.

0
Comment
Question by:HLyder
4 Comments
 
LVL 37

Accepted Solution

by:
Geert Gruwez earned 500 total points
ID: 35074407
0
 
LVL 7

Expert Comment

by:samenglish
ID: 35074571
There is some Delphi code here
http://www.swissdelphicenter.ch/torry/showcode.php?id=2211
http://www.delphi3000.com/articles/article_4841.asp?SK=
http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_24135127.html
http://answers.yahoo.com/question/index?qid=20060703000208AAvsSaN

And more helpful information from a .NET perspective (sometimes you learn more from that than by just looking at sample code)
http://www.developerfusion.com/article/84338/making-usb-c-friendly/
http://social.msdn.microsoft.com/Search/en-GB/?Refinement=126&Query=how+to+detect+usb+device

To deal with the AVs, just enclose your usb related code in a try except block. Try to resist the urge to use the throwing of an exception as an indicator of the device being removed !
0
 

Author Closing Comment

by:HLyder
ID: 35074986
Both responses where usefull, but first-come first serve
0
 
LVL 25

Expert Comment

by:epasquier
ID: 35080152
HLyder, actually you can select multiple answers and share points as you wish, no need to be binary
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now