-1

I want to write a program to disconnect a specific USB device in Windows. Is there a function in windows API that can do this?

I have read the document about USB API but I still cann't find it.

Dai
  • 1
  • 2

1 Answers1

0

Use SetupDiGetClassDevs and CM_Request_Device_Eject. For a complete example, see the reference Safely remove a USB drive using the Win32 API?

YangXiaoPo-MSFT
  • 1,589
  • 1
  • 4
  • 22
  • You can use [CM_Request_Device_Eject](https://learn.microsoft.com/en-us/windows/win32/api/cfgmgr32/nf-cfgmgr32-cm_request_device_ejectw) function to prepare a local device instance for safe removal, if the device is removable. @Dai, Does my answer work for you? – YangXiaoPo-MSFT May 05 '23 at 06:24