• Welcome to Forum.Deepsoftware.Com. Please login or sign up.
 
March 29, 2024, 11:42:00 am

News:

SMF - Just Installed!


Detect HID Devices

Started by moelski, January 26, 2010, 10:01:08 am

Previous topic - Next topic

moelski

Hi Roman,

some time ago I posted a Thread here how to detect devices with WM_DEVICECHANGE. Well I got it working fine with ports. But I have problems with HID devices.

Attached you will find my code for port devices.

If I attach a HID device to the computer I only get DBT_DEVNODES_CHANGED for Msg.WParam. This is a known "problem" in windows because HID devices don´t send DBT_DEVICEREMOVECOMPLETE or DBT_DEVICEARRIVAL. This is a problem for me because I can´t get details about the attached device.

Do you see any change to get a similar mechanism to detect HID devices after they are attached to the computer?

What I wan´t to achieve is to display a message to the User: "Deivce <DEVICENAME> was attached to USB port XY".

If I use DBT_DEVNODES_CHANGED I have two problems:
1) I can´t get any device details.
2) DBT_DEVNODES_CHANGED is send several times if you attach a device to the computer.

Any idea?

Greetz Dominik

moelski

Hi !

No idea on this topic ?

moelski

Hi !

I can´t beleave that there is no answer for my question  :o

Roman Novgorodov

Hello

I'm sorry but I don't understand.
Do you try to run UsbDeviceDemo? Does it refresh USB device list correctly?
Do you try to run HidDemo? Does it refresh HID device list correctly?

If all is ok in these demos just take a look their source code.

Roman Novgorodov
DeepSoftware.Com
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

moelski

Hi Roman,

you missunderstood me.
Your demos all run fine - that´s not the problem. And for sure I took a look into the source codes.

I think it would be more clear if you run my attached demo application.

Let me explain what I wanna do:
If a user plug in a new serial port (USB / Serial converter) or a new HID device I need a popup which shows details about that device. One thing I wanna show is the friendly name of the device.

To achieve this I want to use the WM_DEVICECHANGE windows message. But HID devices only send  DBT_DEVNODES_CHANGED (what I need is DBT_DeviceArrival, DBT_DeviceRemoveComplete to get device details). So how can I read the device details after plugin the device?

Roman Novgorodov

Hello

I understood you correctly.
And I have seen your code. You try to analyze WM_DEVICECHANGE message.

Please note that WM_DEVICECHANGE is only notification message. It has very small details about real event.
It has no device description. Detailed device information is available only in SetupDiXXXX API.

Our demo projects call WMDeviceChange() methods for reload (refresh) internal device list of necessary type.

Roman Novgorodov
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.