Registers a hot plug handle for USB device notification of any supported device.
- hot-plug-monitor example:
- Initializes a new HotK (hot-plug) handle.
- Writes arrival/removal event notifications to console output as they occur.
- Repeats step #2 until the Q key is pressed.
- Frees the HotK (hot-plug) handle created in step #1
- Console Output
Initialize a HotK device notification event monitor..
Looking for devices with instances IDs matching the pattern '*'..
Press 'q' to exit..
HotK monitor initialized. ErrorCode: 00000000h
[ARRIVAL] Benchmark Device (Microchip Technology, Inc.) [libusbK]
InstanceID : USB\VID_04D8&PID_FA2E\LUSBW1
DeviceInterfaceGUID : {716cdf1f-418b-4b80-a07d-1311dffdc8b8}
DevicePath : \\?\USB#VID_04D8&PID_FA2E#LUSBW1#{716cdf1f-418b-4b80-a07d-1311dffdc8b8}
[REMOVAL] Benchmark Device (Microchip Technology, Inc.) [libusbK]
InstanceID : USB\VID_04D8&PID_FA2E\LUSBW1
DeviceInterfaceGUID : {716cdf1f-418b-4b80-a07d-1311dffdc8b8}
DevicePath : \\?\USB#VID_04D8&PID_FA2E#LUSBW1#{716cdf1f-418b-4b80-a07d-1311dffdc8b8}
HotK monitor closed. ErrorCode: 00000000h
{
UNREFERENCED_PARAMETER(Handle);
printf(
"\n"
"[%s] %s (%s) [%s]\n"
" InstanceID : %s\n"
" DeviceInterfaceGUID : %s\n"
" DevicePath : %s\n"
" \n",
}
DWORD __cdecl main(int argc, char* argv[])
{
DWORD errorCode = ERROR_SUCCESS;
CHAR chKey;
memset(&hotParams, 0, sizeof(hotParams));
printf("Initialize a HotK device notification event monitor..\n");
{
errorCode = GetLastError();
printf("HotK_Init failed. ErrorCode: %08Xh\n", errorCode);
goto Done;
}
printf("HotK monitor initialized successfully!\n");
printf("Press 'q' to exit...\n\n");
for(;;)
{
if (_kbhit())
{
chKey = (CHAR)_getch();
if (chKey == 'q' || chKey == 'Q')
break;
chKey = '\0';
continue;
}
Sleep(100);
}
{
errorCode = GetLastError();
printf("HotK_Free failed. ErrorCode: %08Xh\n", errorCode);
goto Done;
}
printf("HotK monitor closed successfully!\n");
Done:
return errorCode;
}