开发者

Determine what physical hard drive a file is on?

How can I find the physical drive a file/direct开发者_开发百科ory is located on. I want to compare 2 files and if they are on two separate drives, then I can speed up the compare by reading both simultaneously.

Regards


This may require P/Invoke.

Way to know if two partitions are in one physical hard disk without WMI?

From above link:

The Win32 function you'll need is called DeviceIoControl(). The API documentation can be found at http://msdn.microsoft.com/en-us/library/aa363216(VS.85).aspx. Call DeviceIoControl() with the control code IOCTL_STORAGE_GET_DEVICE_NUMBER and you'll get the physical disk drive for the given partition device handle. The device handle for the partition can be retrieved using CreateFile() API.


Read both simultaneously regardless.

At worst it might be slightly slower (depends on the actual physical disk(s)).

At best it will be faster.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜