Title: How to simulate a USB unplug/replug after the device is safely removed?
Tags: windows-7;windows-vista;usb;device-driver
Question: If I send IOCTL_INTERNAL_USB_CYCLE_PORT I/O request to the USB device, it works as unplug and replug. but if I safely removed it from the system tray, then send the same request, I get 0xC000000E error code, which is STATUS_NO_SUCH_DEVICE, and the device won't reappear. Is there a way to simulate a replug of this USB device in a "safely removed but physically connected" state?
From Microsoft's USB Reference:
The IOCTL_INTERNAL_USB_CYCLE_PORT I/O
request simulates a device unplug and
replug on the port associated with the
PDO.

Here is the accepted answer: You should send IOCTL this to the parent of the device - not to the device itself.


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 2.5', 'CreationDate': '2011:00:03/14/11', 'FavoriteCount': 1.0, 'PostTypeId': 1, 'Tags': '<windows-7><windows-vista><usb><device-driver>', 'Title': 'How to simulate a USB unplug/replug after the device is safely removed?', 'ViewCount': 3602, 'id': 5297304, 'user_AboutMe': '<ul>\n<li><p>Bio</p>\n<ul>\n<li>Software Developer, System Engineer</li>\n<li>Salesforce &lt;- Signifyd &lt;- Nutanix &lt;- VMware &lt;- Oracle</li>\n<li>San Francisco/Bay Area &lt;- Beijing China</li>\n</ul>\n</li>\n<li><p>Current focus</p>\n<ul>\n<li>Bigdata pipeline</li>\n</ul>\n</li>\n<li><p>I also know something about</p>\n<ul>\n<li>Applied Machine Learning</li>\n<li>Python, Bash, C, gdb, Linux</li>\n<li>Whole Stack Development/Debugging</li>\n<li>Memory/Core Dump Analysis</li>\n<li>Virtual Device, USB, ...</li>\n</ul>\n</li>\n</ul>\n', 'user_AccountId': 77788.0, 'user_DisplayName': 'Dyno Fu', 'user_Reputation': 8434.0, 'user_Views': 867.0, 'user_id': 221794.0}}