WM_DEVICECHANGE The WM_DEVICECHANGE device message notifies an application or device driver of a change to the hardware configuration of a device or the computer.Event = (UINT) wParam; dwData = (DWORD) lParam;
Parameters Event Event type. This parameter can be one of the following values: Value Meaning DBT_CONFIGCHANGECANCELED A request to change the current configuration (dock or undock) has been canceled. DBT_CONFIGCHANGED The current configuration has changed, due to a dock or undock. DBT_DEVICEARRIVAL A device has been inserted and is now available. DBT_DEVICEQUERYREMOVE Permission is requested to remove a device. Any application can deny this request and cancel the removal. DBT_DEVICEQUERYREMOVEFAILED A request to remove a device has been canceled. DBT_DEVICEREMOVECOMPLETE A device has been removed. DBT_DEVICEREMOVEPENDING A device is about to be removed. Cannot be denied. DBT_DEVICETYPESPECIFIC A device-specific event has occurred. DBT_QUERYCHANGECONFIG Permission is requested to change the current configuration (dock or undock). DBT_USERDEFINED The meaning of this message is user-defined. dwData Address of a structure that contains event-specific data. Its meaning depends on the given event. Return Values Return TRUE to grant a requested action.Return BROADCAST_QUERY_DENY to deny a requested action.Res For devices that offer software-controllable features, such as ejection and locking, the system typically sends a DBT_DEVICEREMOVEPENDING message to let applications and device drivers end their use of the device gracefully. If the system forcibly removes a device, it may not send a DBT_DEVICEQUERYREMOVE message before doing so.DBT_CONFIGCHANGECANCELED, DBT_CONFIGCHANGED, DBT_DEVICEARRIVAL, DBT_DEVICEQUERYREMOVE, DBT_DEVICEQUERYREMOVEFAILED, DBT_DEVICEREMOVECOMPLETE, DBT_DEVICEREMOVEPENDING, DBT_DEVICETYPESPECIFIC, DBT_QUERYCHANGECONFIG, DBT_USERDEFINED QuickInfo Windows NT: Requires version 4.0 or later. Windows: Requires Windows 95 or later. Windows CE: Unsupported. Header: Declared in winuser.h.See Also System Messages Overview, System Message Messages
The WM_DEVICECHANGE device message notifies an application or device driver of a change to the hardware configuration of a device or the computer.Event = (UINT) wParam;
dwData = (DWORD) lParam;
Parameters
Event
Event type. This parameter can be one of the following values: Value Meaning
DBT_CONFIGCHANGECANCELED A request to change the current configuration (dock or undock) has been canceled.
DBT_CONFIGCHANGED The current configuration has changed, due to a dock or undock.
DBT_DEVICEARRIVAL A device has been inserted and is now available.
DBT_DEVICEQUERYREMOVE Permission is requested to remove a device. Any application can deny this request and cancel the removal.
DBT_DEVICEQUERYREMOVEFAILED A request to remove a device has been canceled.
DBT_DEVICEREMOVECOMPLETE A device has been removed.
DBT_DEVICEREMOVEPENDING A device is about to be removed. Cannot be denied.
DBT_DEVICETYPESPECIFIC A device-specific event has occurred.
DBT_QUERYCHANGECONFIG Permission is requested to change the current configuration (dock or undock).
DBT_USERDEFINED The meaning of this message is user-defined.
dwData
Address of a structure that contains event-specific data. Its meaning depends on the given event.
Return Values
Return TRUE to grant a requested action.Return BROADCAST_QUERY_DENY to deny a requested action.Res
For devices that offer software-controllable features, such as ejection and locking, the system typically sends a DBT_DEVICEREMOVEPENDING message to let applications and device drivers end their use of the device gracefully. If the system forcibly removes a device, it may not send a DBT_DEVICEQUERYREMOVE message before doing so.DBT_CONFIGCHANGECANCELED, DBT_CONFIGCHANGED, DBT_DEVICEARRIVAL, DBT_DEVICEQUERYREMOVE, DBT_DEVICEQUERYREMOVEFAILED, DBT_DEVICEREMOVECOMPLETE, DBT_DEVICEREMOVEPENDING, DBT_DEVICETYPESPECIFIC, DBT_QUERYCHANGECONFIG, DBT_USERDEFINED QuickInfo
Windows NT: Requires version 4.0 or later.
Windows: Requires Windows 95 or later.
Windows CE: Unsupported.
Header: Declared in winuser.h.See Also
System Messages Overview, System Message Messages
当然了,说不定有些UKEY的api早给放到网络上了,找找说定也能找到!
// Register to receive notification when a USB device is plugged in.
broadcastInterface.dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE);
broadcastInterface.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE; memcpy( &(broadcastInterface.dbcc_classguid),
&(GUID_CLASS_USB_DEVICE),
sizeof(struct _GUID)); gNotifyDevHandle = RegisterDeviceNotification(hWnd,
&broadcastInterface,
DEVICE_NOTIFY_WINDOW_HANDLE); // Now register for Hub notifications.
memcpy( &(broadcastInterface.dbcc_classguid),
&(GUID_CLASS_USBHUB),
sizeof(struct _GUID)); gNotifyHubHandle = RegisterDeviceNotification(hWnd,
&broadcastInterface,
DEVICE_NOTIFY_WINDOW_HANDLE);
size_t szAllDriveStrings = GetLogicalDriveStrings(0,NULL);
char *pDriveStrings = new char[szAllDriveStrings + sizeof(_T( " "))];
GetLogicalDriveStrings(szAllDriveStrings,pDriveStrings);
size_t szDriveString = strlen(pDriveStrings);
while(szDriveString > 0)
{
AfxMessageBox(pDriveStrings);
pDriveStrings += szDriveString + 1;
szDriveString = strlen(pDriveStrings);
} // pDriveStrings 就索盘符撒
--------------------------------------------------------------- DiskType=GetDriveType(strTempDirver);
switch(DiskType)
{
case DRIVE_NO_ROOT_DIR:
return;
case DRIVE_REMOVABLE:
//::AfxMessageBox( "移动存储设备 ");
break;
case DRIVE_FIXED:
//::AfxMessageBox( "固定硬盘驱动器 ");
break;
case DRIVE_REMOTE:
//::AfxMessageBox( "这是网络驱动器 ");
return;
case DRIVE_CDROM:
//::AfxMessageBox( "这是光盘驱动器 ");
return;