While Getting the message WM_DEVICECHANGE ( either device arrival/romal (DBT_DEVICEARRIVAL/DBT_DEVICEREMOVEPENDING....), how we may able to get the device name

like KingstonDataTraveler_2.01

PDEV_BROADCAST_HANDLE pDBHandle  =(PDEV_BROADCAST_HANDLE) lParam;
if(pDBHandle->dbch_handle !=INVALID_HANDLE_VALUE)
{
STORAGE_PROPERTY_QUERY query;
DWORD cbBytesReturned = 0;
char buffer [10000];
memset ((void *) & query, 0, sizeof (query));
query.PropertyId = StorageDeviceProperty;
query.QueryType = PropertyStandardQuery;
 memset (buffer, 0, sizeof (buffer));
 BOOL b =DeviceIoControl (pDBHandle->dbch_handle, IOCTL_STORAGE_QUERY_PROPERTY,
                   & query,
                   sizeof (query),
                   & buffer,
                   sizeof (buffer),
                   & cbBytesReturned, NULL);

But is b false and getlast error is INVALID_HANDLE_VALUE

can you suggest some method to get device name at device arrival & device removal

Thanks in Advance
Dileep Subramanian

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.