VB 6.0 中,已知\Device\HarddiskVolume1\Windows\System32\svchost.exe ,获取其盘符

目前已获取路径为\Device\HarddiskVolume1\Windows\System32\svchost.exe ,
想转换成 “盘符”\Windows\System32\svchost.exe ,
例:C:\Windows\System32\svchost.exe
不能确定Device是否只有1个硬盘,不能确定HarddiskVolume1是否只是C盘,因为用户可能有2个硬盘,而系统不一定装在C。
请用VB6.0代码
或问询 QueryDosDevice在VB中的具体用法、也就是通过循环盘符获取每个盘符所对应的\Device\HarddiskVolume1
最新回答
我污但不色

2025-03-27 01:26:23

dim str1 as string
str1="\Device\HarddiskVolume1\Windows\System32\svchost.exe"
dim a() as string
a=split(str1,"\")
//如果是C盘的话,直接连接字符串就行了
dim str2 as string
str2="c:"
for i=3 to ubound(a)-1
str2=str2 & "\" & a(i)
next i
//str2就是你想要的路径。
玥天竺灭仄

2025-03-27 03:03:20

用GetLocalDrivers 遍历QueryDosDevice 查找替换字符即可。