Well, thanks. I'll wait a few days, if nobody give a sample code I accept your comment as answer.
Main Topics
Browse All Topics[env: Win2k, MS Visual C++ 7.0, Borland C++ Builder 5.0]
Hi,
I can't get working WM_DEVICECHANGE message. I've found number of samples in MSDN and other places. But this message does not seem to arrive neither to my applications nor samples I've found around the Internet..
I've discovered that there is RegisterDeviceNotification
Thanks in advance.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I get WM_DEVICECHANGE messages for a custom USB device without calling RegisterDeviceNotification
a) you get more than one, and I didn't find the additional info meaningful (however, USB documentation was still scarce when I implemented that)
b) while processing the message, I cannot find the device even when it's there. a simple PostMessage - decoupling solved this even with all "evil timing" attempts on all systems
however, for me it was enough to know that "something" happened, and to re-enumerate devices after that.
I should clarify...
You have to register for device notification on 2000 and XP. Windows 95/98/Me seem to send this message without notification. (I don't believe they support the RegisterDeviceNotifcation API anyway)
On XP you'll receive a message with wParam=7 and lParam=0 when there is some type of change, but you don't know what it is.
Hi Alisher,
Problem is my application does not get WM_DEVICECHANGE message when user insert/removes CD under Win2k/XP. So I need to use RegisterDeviceNotification
http://msdn.microsoft.com/
I woould be happy to look at your code - if it will help I accept your comment as answer. If you could, please send sample to mikle@tomsk.net.
Thanks.
I just checked my all code... there is a bad news and good news ;-)
the bad news is that delphi doesn't need any registration for message handlers (it is done on startup internally)
so I declare my handler like:
procedure WMDeviceChange(var msg: TWMDeviceChange); message WM_DEVICECHANGE;
and then write my code in procedure (this is a test):
...
memo1.Lines.Add( 'got WM_DEVICECHANGE message!' );
...
there is nothing else I have to do! no register notification etc etc...
the good news - it works just fine ;-), I checked my USB mouse removal/plug and CD disk change, it works on my system perfectly (w2k)...
what I suggest - I am sending you this my test program compiled with delphi, it shows you in memo area all messages, try to run it and remove/insert CD and look if it works on your system... then we can go further to understand your registration problem...
and about your question 'how to get GIUD' I think this an appropriate function
http://msdn.microsoft.com/
and this a full code example doing what you need and it does not mention any special registration function to be used
http://msdn.microsoft.com/
Business Accounts
Answer for Membership
by: djdjPosted on 2002-11-11 at 19:48:32ID: 7436425
The problem with WM_DEVICECHANGE on W2K/WXP is that you have to register for the devices you want notification for using the RegisterDeviceNotification API.
Unfortunately I've never gotten it to work myself. But that should point you in the general direction you need to go.