简体   繁体   English

如何从网络逻辑磁盘名称获取物理磁盘索引?

[英]How to get physical disk index from network logical disk name?

I'm writing a program which will be able to show hdd disk performance. 我正在写一个程序,它将能够显示硬盘的性能。 Input data for the program is logical disk name("D:","E:"etc.). 程序的输入数据是逻辑磁盘名称(“ D:”,“ E:”等)。 I have to get physical disk index from logical disk name. 我必须从逻辑磁盘名称获取物理磁盘索引。 There are no problem for local machine. 本地计算机没有问题。 I can do this like: 我可以这样做:

 HANDLE h = ::CreateFile( L"\\\\.\\d:" , 0 , 0 , NULL , OPEN_EXISTING, 0 , NULL);  
  STORAGE_DEVICE_NUMBER info = { };   
   DWORD bytesReturned = 0;
   ::DeviceIoControl( h , IOCTL_STORAGE_GET_DEVICE_NUMBER , NULL , 0,&info,sizeof( info ) , &bytesReturned , NULL );

then use info.DeviceNumber for further usage. 然后使用info.DeviceNumber进行进一步使用。 But i don't know how to do the same for network drive. 但是我不知道如何为网络驱动器做同样的事情。 How can I change local path L"\\\\\\\\.\\\\D:" if i need get handle of network logic drive "D:" at server named "server1" . 如果需要在名为"server1"服务器上获取网络逻辑驱动器“ D:”的句柄,如何更改本地路径L"\\\\\\\\.\\\\D:" "server1" I have tried L"\\\\\\\\server1\\\\\\\\.\\\\D:" , L"server1\\\\\\\\.\\\\D:" etc. but it hasn't helped. 我已经尝试过L"\\\\\\\\server1\\\\\\\\.\\\\D:"L"server1\\\\\\\\.\\\\D:"等,但是它没有帮助。

You can't. 你不能 There's no support in the network protocol to request that sort of information. 网络协议不支持请求此类信息。 server1 might not even have the notion of a "physical disk index". server1甚至可能没有“物理磁盘索引”的概念。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM