USB Endpoint (Using USB as serial) Connect/Disconnect Notification

We are developing our application using colibri evk board( imx7 processor) running wince provided by Toradex. We are using one of USB port as serial.

Is there any method to identify that USB is Connected/Disconnected i.e. we want a notification that signal our device that external device connected over USB is connected/disconnected ?

Dear @bipin7301

It should be possible to react on the WM_DEVICECHANGE windows message. I didn’t test the code below, therefore I appreciate your feedback whether it works.

...
if (msg->message == WM_DEVICECHANGE)
{
    PDEV_BROADCAST_HDR pDevHdr = (PDEV_BROADCAST_HDR) msg->lParam;
    char name[256] = {0} ;
    switch(msg->wParam)
    {
        case DBT_DEVICEARRIVAL:
            if (pDevHdr->dbch_devicetype == DBT_DEVTYP_PORT)
            {
                PDEV_BROADCAST_PORT pPort = (PDEV_BROADCAST_PORT)pDevHdr;
                // device name in pPort->dbcp_name
            }
            break ;
        
        case DBT_DEVICEREMOVECOMPLETE:
            if (pDevHdr->dbch_devicetype == DBT_DEVTYP_PORT)
            {
                PDEV_BROADCAST_PORT pPort = (PDEV_BROADCAST_PORT) pDevHdr ;
                // device name in pPort->dbcp_name
            }
            break ;
    }
}
...

Regards, Andy