问题
I am having a Vodaphone data card which can be inserted in a USB port.
I have XP and Vista OS, and I am using WM_DEVICECHANGE
event of Windows, to know USB Insertion and removal, and it's working fine for me.
But I am not able to differentiate between Data card insertion and Pen drive insertion. Is it possible?
回答1:
Yes. The "pen drive" and "data card" implement different interfaces. You will have subscribed using RegisterDeviceNotification for DEV_BROADCAST_DEVICEINTERFACE
. The LPARAM of the WM_DEVICECHANGE
you get back will then be a DEV_BROADCAST_DEVICEINTERFACE*
. This structure has a dbcc_classguid
member. This will be GUID_DEVINTERFACE_VOLUME
for your pen drive, and something else for your datacard - experiment.
来源:https://stackoverflow.com/questions/1077968/differentiating-between-data-card-and-pen-drive-or-usb-flash-drive