Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to programmatically connect and reconnect usb device

Tags:

delphi

usb

I am modifying the partition table of an Usb Device for encryption purposes.

The code works fine but i need to unplug and plug the usb device to see changes how can i do this programmatically ?

I know is possible because some other apps do it.Currently i use DeviceIoCtrl to remove the usb device and tell the user to do the operation manually but it's not professional.

I tried to use IOCTL_INTERNAL_USB_CYCLE_PORT but that is not supported i guess it can be called only from kernel mode.

like image 740
opc0de Avatar asked Nov 05 '22 17:11

opc0de


1 Answers

The Remarks for IOCTL_DISK_UPDATE_PROPERTIES suggest it's the correct IOCTL to use when you have directly modified the partition table and wish to reload it.

This operation is used in synchronizing the system view of the specified disk device when the partition table of the disk is directly modified. Be sure to perform this operation when you update the usable space for a disk so that the system will update its partition table.

like image 110
Brian Avatar answered Nov 09 '22 11:11

Brian