Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Embedded C++ C Windows USB Driver , +
Hello friends,
I use CODE::BLOCKS in Windows vista.
I would like to write a program on USB, that, when a pen drive or something is connected to the USB port my program should warn me that something is connected.
I would like to write the same in C or C++ language.
Please provide me some tips.
I think I can make it out from registry. If yes, then I would like to know what will be value of registry key before and after USB drive connected. Because I did not find any difference.
Please help me.
Posted 24-May-12 3:22am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

  Permalink  
Comments
Sergey Chepurin at 26-May-12 5:43am
   
The OP's user name is "rasmiranjanbabu". But probably, he is known to somebody as "Sergey".
Volynsky Alex at 26-May-12 13:32pm
   
Sorry,
I mean rasmiranjanbabu
 
Regards,
Alex
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

It is not exactly clear to me if you want to be able to scan through the connected devices (on program startup) or detect when devices are added/removed on the fly. If you want to detect the changes, I recommend taking a look at this CodeProject article:
 
www.codeproject.com/Articles/14500/Detecting-Hardware-Insertion-and-or-Removal[^]
 
It is written in C++ and I found it easy to use the code for detecting when USB COM port devices are added and removed.
 

Soren Madsen
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Hi
 
The link below might be helpful:
How to enumerate hardware devices by using SetupDi calls[^]
 
MSDN:Public Device Installation Functions[^]
 
I like using DevCon.exe in WinDDK. (Src code: WinDDK\*version\src\setup\devcon)
This should have enough info to enumerate connected devices.
http://msdn.microsoft.com/en-us/library/windows/hardware/ff544707(v=vs.85).aspx[^]
 
If you want to monitor the connection, you might wanna use Timer using the API above and constantly watch the changes.
 
Good luck,
Sean
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Have you read this codeproject article.. It have some useful inputs for you
 

HIDAche - An Exercise in Hardware/Software Integration
 
The following link the related links in StackOverflow might help you
 
http://stackoverflow.com/questions/7964639/net-programming-and-interfacing-with-a-usb-device
  Permalink  
v2
Comments
rasmiranjanbabu at 24-May-12 9:00am
   
@JimJos: I have gone through the links, but does not serve my needs.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Advise you to always search Codeproject.com first. Accidentally, there is a good article on this very topic - Simple URB (USB Request Block) Monitor[^].
But there is even better sample "USB Device Viewer" in Windows DDK (in C:\WinDDK\7600.16385.1\src\usb\usbview). But it does not constantly "monitor" ports (that functionality you could, probably, add by yourself).
P.S. I was wrong, it has option "Auto Refresh".
  Permalink  
v4

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



Advertise | Privacy | Mobile
Web04 | 2.8.150302.1 | Last Updated 26 May 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100