确定文件位于哪个物理硬盘驱动器上?

发布于 2024-10-20 15:22:13 字数 86 浏览 6 评论 0原文

如何找到文件/目录所在的物理驱动器。我想比较 2 个文件,如果它们位于两个单独的驱动器上,那么我可以通过同时读取两个文件来加快比较速度。

问候

How can I find the physical drive a file/directory 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

自我难过 2024-10-27 15:22:13

这可能需要 P/Invoke。

了解是否存在的方法两个分区位于一个物理硬盘上,没有 WMI?

来自上面的链接:

您需要的 Win32 函数称为 DeviceIoControl()。 API 文档可以在 http://msdn 中找到。 microsoft.com/en-us/library/aa363216(VS.85).aspx。使用控制代码 IOCTL_STORAGE_GET_DEVICE_NUMBER 调用 DeviceIoControl(),您将获得给定分区设备句柄的物理磁盘驱动器。可以使用 CreateFile() API 检索分区的设备句柄。

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.

青瓷清茶倾城歌 2024-10-27 15:22:13

无论如何,同时阅读两者。

在最坏的情况下,它可能会稍微慢一些(取决于实际的物理磁盘)。

充其量会更快。

Read both simultaneously regardless.

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

At best it will be faster.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文