#code=936
IFEX X.LOG, LOGS * X.LOG

//直接获取盘符对应的Volume
_SUB GetVol  //盘符:  Var
    SET$ &Buf=*1000 0
    SET &DPATH=%1
    CALL $--qd Kernel32.dll,GetVolumeNameForVolumeMountPointW,$%DPATH%\,*Buf,#1000
    ENVI-ret %2=%&Buf%
_END

//获取盘符或分区对应的Volume
_SUB GetPtVol  // Drv hd   pt  VarVolume  [VarDrv]
    ENVI-ret %4=
    ENVI-ret %5=
    SET &Drv=%~1
    SET &hd=%~2
    SET &pt=%~3
    SET &DrvN=
    @TEAM SET &_phy=| SET &SP=
    FIND $%&Drv%=, 
    {*
    CALC -err=-1 &hd=(%&hd%)
    IFEX $%&hd%<0, EXIT
    LSTR &&pt1=1,%&pt%
    FIND $%&pt1%=#, SET &_phy=-phy! FIND $%&pt1%<>:, SET SP=:
    PART %&_phy% list part %&hd%%&SP%%&pt%,&&V
    MSTR &&drv=<8>%&V%
    @FIND $%&Drv%=, @TEAM FDRV *idle *rsort &&Drvs=*:| MSTR &&Drv=<1>%&Drvs%| SET &DrvN=Tmp| SHOW * %&hd%%&SP%%&pt%, %&DRV%
    }
    FIND $%&Drv%=, EXIT
    SET$ &Buf=*1000 0
    CALL $--qd Kernel32.dll,GetVolumeNameForVolumeMountPointW,$%&Drv%\,*Buf,#1000
    FIND $%&DrvN%<>,  SUBJ *- %&DRV%
    ENVI-ret %4=%&Buf%
    ENVI-ret %5=%&Drv% %&DrvN%
_END

GetVol C: Volu
MESS C: [%Volu%]

GetPtVol "C:" "" "" Volu1  Drv
MESS C:\ [%Volu1%]


GetPtVol ""  0 :1 Volu2  Drv  //逻辑号
MESS 0:1 [%Volu2%] [%Drv%]

GetPtVol ""  0 #5 Volu3  Drv  //物理号
MESS 0#5 [%Volu3%] [%Drv%]@
