ENVI^  EnviMode=1
ENVI^  ForceLocal=1

WinDiskList
_SUB WinDiskList,W600H200,磁盘列表
    GetAllDisk  &&磁盘LIST &&D1 7 //USB
    //GetAllDisk  &&磁盘LIST  &&D1 //ALL
    LIST   PHYDRV,L20T20W528H232,%&磁盘LIST%,,%&D1%
_END

//GetAllDisk 返回变量名 [第一个名] [过滤类型]
_SUB GetAllDisk //USB
    SET &filtp=%~3
    FDRV &Drvs=*:
    FORX * %&Drvs%,&D,
    {*
        PART list drv %&D%,&&V
        MSTR &&hd=<9>%&V%
        ^SET &Drv[%&hd%]=%%&Drv[%&hd%]%%%&D%
    }


    PART list disk,&&全部磁盘
    ENVI &&磁盘LIST=
    SET &D1=
    forx * %&全部磁盘%,&磁盘,
    {*
        PART -devidx list disk %&磁盘%,&&iDskInf
        MSTR &&hd,&&SZ,&&Bus,&&DskID=<1><2><9><~12>%&iDskInf%
        FIND $%&DskID%=,
        {*  TEAM PART -devid list disk %&磁盘%,&&iDskInf|MSTR &&DskID=<~12>%&iDskInf%
            SED &DskID=1,USBSTOR\\DISK\&VEN_,,%&DskID%
            SED &DskID=1,\&REV.*,,%&DskID%
            SED &DskID=1,\&,_,%&DskID%
        }
        FIND $%&DskID%=, SET DskID=-
        FIND $%filtp%<>,IFEX #%Bus%<>%filtp%, EXIT -  //只要USB
        IFEX #%Bus%=2, SET Bus=(ATAPI)
        IFEX #%Bus%=3, SET Bus=(ATA)
        IFEX #%Bus%=7, SET Bus=(USB)
        IFEX #%&SZ%>2G, @TEAM CALC &SZ=%&SZ%/1G#3| SET SZ=%&SZ%G! IFEX #%&SZ%>2M, @TEAM CALC &SZ=%&SZ%/1M#1| SET SZ=%&SZ%M
        ^SET &磁盘LIST=%&磁盘LIST%|%&磁盘% %&Bus% %&SZ% %&DskID% %%&Drv[%hd%]%%
        FIND $%&D1%=, ^SET &D1=%&磁盘% %&Bus% %&SZ% %&DskID% %%&Drv[%hd%]%%
    }
    ENVI-ret  %~1=%&磁盘LIST%
    ENVI-ret  %~2=%&D1%
_END
