From: Maxim S. Shatskih on
> I need a number or device ID that will not change every time the system
> starts up.

Port number will change on each re-plug.

> generic USB keyboard given a device name "\.\Device\000000XXX"?

If there is no unique ID in the USB config descriptor of the keyboard - then just plain impossible.

--
Maxim S. Shatskih
Windows DDK MVP
maxim(a)storagecraft.com
http://www.storagecraft.com

From: Philip Ries [MSFT] on
I don't know if you have the device instance path for each device. If
you do, or you can get it, you can make some SetupDi function calls to
get the port number. The sequence look something like:

SetupDiGetClassDevs
SetupDiEnumDeviceInfo
SetupDiGetDeviceProperty (DEVPKEY_Device_Address)

Reference: "Address" section at
http://msdn.microsoft.com/en-us/library/dd852021.aspx

MAV wrote:
> "Maxim S. Shatskih" wrote:
>
>> So, it is not a good idea to use USB port numbers anywhere. Use device instances instead, strongly tied to the device's embedded unique ID and not the port it is connected too. This is well-supported in Windows using PnP.
>
> I need a number or device ID that will not change every time the system
> starts up. Could you please tell me how to retrieve such unique ID for
> generic USB keyboard given a device name "\.\Device\000000XXX"? Maybe to send
> some IOCTL's ?
From: guest on
I think this is exactly what you need: http://msdn.microsoft.com/en-us/library/ms790939.aspx


HidD_GetSerialNumberString

---
frmsrcurl: http://msgroups.net/microsoft.public.development.device.drivers/How-to-uniquely-identify-a-USB-HID-device