Solved

is the usb inserted and the driver loaded, delphi programming

Posted on 2011-03-08
4
502 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 36

Accepted Solution

by:
Geert Gruwez earned 500 total points
Comment Utility
0
 
LVL 7

Expert Comment

by:samenglish
Comment Utility
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
Comment Utility
Both responses where usefull, but first-come first serve
0
 
LVL 25

Expert Comment

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

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

762 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

6 Experts available now in Live!

Get 1:1 Help Now