开发者

How to programmatically connect and reconnect usb device

开发者 https://www.devze.com 2023-03-24 04:06 出处:网络
I am modifying the partition开发者_开发知识库 table of an Usb Device for encryption purposes.

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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消