@TEAM ENVI^ ForceLocal=1| ENVI^ EnviMode=1

SET$ &NL=0d 0a

SET &VHD="Q:\VHDTEST\BASE_S1_S1.vhd"

SET &Vmsg=
SET#%  &V=*8192 
{  //VHD长度
ENVI-mkfixdummy   &&nm=&V@12;~
//SET-int64 V=1:0
SET-int64 V=0:8
MOUN -vhd -query -r  %&VHD%,&V,&bytes,1
SET?int64 V=&szv:8
SET?int64 V=&szp:16
IFEX #%&bytes%>=24,  SET< Vmsg=%NL%bytes[%&bytes%] szv[%&szv%] szp[%&szp%]! SET< Vmsg=%NL%FAIL bytes[%&bytes%] szv[%&szv%] szp[%&szp%]
}



{    //差分VHD 的 父亲
//SET-int64 V=3:0
SET-int64 V=0:8
MOUN -vhd -query -r  %&VHD%,&V,&bytes,3
SET?long V=&&ParentResolved:8
ENVI-mkfixdummy   &&nm=&V@12;~
IFEX #%&bytes%>=16,  SET< Vmsg=%NL%bytes[%bytes%] [%ParentResolved%] [%&nm%]! SET< Vmsg=%NL%FAIL bytes[%bytes%] [%ParentResolved%] [%&nm%]
}


{ // 类型
//SET-int64 V=6:0  //GET_VIRTUAL_DISK_INFO_VIRTUAL_STORAGE_TYPE
SET-int64 V=0:8
MOUN -vhd -query -r  %&VHD%,&V,&&bytes,6
ENVI?long &V=&&tp:8   //2=VIRTUAL_STORAGE_TYPE_DEVICE_VHD  3=VIRTUAL_STORAGE_TYPE_DEVICE_VHDX
IFEX #%&bytes%>=12, SET< Vmsg=%NL%bytes[%&bytes%] type[%&tp%]! SET< Vmsg=%NL%FAIL bytes[%&bytes%] type[%&tp%]
}


{ //子类型
//SET-int64 V=7:0  //GET_VIRTUAL_DISK_INFO_PROVIDER_SUBTYPE
SET-int64 V=0:8
MOUN -vhd -query -r %&VHD%,&V,&bytes,7
ENVI?long &V=&&subtp:8   //2=Fixed.  3=Dynamically  4=Differencing
IFEX #%&bytes%>=12, SET< Vmsg=%NL%bytes[%&bytes%] subtype[%&subtp%]! SET< Vmsg=%NL%FAIL bytes[%&bytes%] subtype[%&subtp%]
}
MSTR * &Vmsg=3,0,&Vmsg
MESS. %&Vmsg%
