确定一个文件是什么物理硬盘驱动器? [英] Determine what physical hard drive a file is on?

查看:136
本文介绍了确定一个文件是什么物理硬盘驱动器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何找到物理驱动器中的文件/目录位于。我想比较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.

问候

推荐答案

这可能需要的P / Invoke

This may require P/Invoke.

办法知道,如果两个分区都在一个物理硬盘,而不WMI ?

从上面的链接:

Win32函数你将需要被调用的DeviceIoControl()。 API文档可以在 http://msdn.microsoft找到.COM / EN-US /库/ aa363216(VS.85)的.aspx 。调用的DeviceIoControl()与控制代码IOCTL_STORAGE_GET_DEVICE_NUMBER,你会得到对给定分区设备处理物理磁盘驱动器。该分区的设备句柄可以使用的CreateFile()API进行检索。

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.

这篇关于确定一个文件是什么物理硬盘驱动器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆