Delphi - 将物理路径(设备文件句柄)转换为虚拟路径 [英] Delphi - convert physical path (device File handle) to virtual path

查看:446
本文介绍了Delphi - 将物理路径(设备文件句柄)转换为虚拟路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将

\Device\HarddiskVolume3\Windows

\Device\HarddiskVolume3\Windows

其对应的虚拟路径? (例如c:\Windows)

into its corresponding virtual path? (like c:\Windows in this case)

推荐答案

我个人喜欢本机方式:

function GetHDDDevicesWithDOSPath:TStringlist;
var
  i: integer;
  root: string;
  device: string;
  buffer: string;
begin
  setlength(buffer, 1000);
  result:=TStringlist.create;
  for i := Ord('c') to Ord('z') do
  begin
    root := Char(i) + ':';
    if (QueryDosDevice(PChar(root), pchar(buffer), 1000) <> 0) then
    begin
      device := pchar(buffer);
      result.add(format('%s = %s\',[device, root ]));
    end;
  end;
end;

NB :此代码示例取自: http://www.delphipraxis.net/165249-auflistung-devices.html

NB: This code sample is taken from: http://www.delphipraxis.net/165249-auflistung-devices.html

这将返回逻辑驱动器和路径之间的映射。在我的情况下:

This will return a map between logical drive and path. In my case:

\Device\HarddiskVolume2 = c:\
\Device\HarddiskVolume3 = d:\
\Device\IsoCdRom0 = e:\
\Device\CdRom0 = f:\
\Device\hgfs\;Z:0000000000084af9\vmware-host\Shared Folders = z:\

您必须替换\您的路径中的device \harddisk部分与相应的驱动器号。

You have to replace "\device\harddisk" part in your path with coresponding drive letter.

请注意,驱动器号是用户依赖的。
一些有用的链接:

Please, note drive letters are user dependent. Some useful links:

这篇关于Delphi - 将物理路径(设备文件句柄)转换为虚拟路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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