applicationname="磁盘空间查看脚" border="dialog" borderstyle="normal" caption="yes" contextmenu="no" maximizebutton="no" minimizebutton="yes" navigable="no" scroll="yes" selection="no" showintaskbar="yes" singleinstance="yes" sysmenu="yes" version="1.0" windowstate="normal" > window.resizeTo 500, 420 ileft=(window.screen.width-500)/2 itop=(window.screen.height-420)/2 window.moveTo ileft,itop Sub Window_onLoad GetDiskSpace End Sub Sub GetDiskSpace Const HARD_DISK = 3 Const Size = 1048576 strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colDisks = objWMIService.ExecQuery _ ("Select * from Win32_LogicalDisk Where DriveType = " & HARD_DISK & "") strHTML = " strHTML = strHTML & " strHTML = strHTML & " strHTML = strHTML & " strHTML = strHTML & " strHTML = strHTML & " strHTML = strHTML & " For Each objDisk In colDisks intFreeSpace = objDisk.FreeSpace/Size intTotalSpace = objDisk.Size/Size pctFreeSpace = intFreeSpace/Size/ intTotalSpace/Size infFuLin = intTotalSpace-intFreeSpace DeviceID = objDisk.DeviceID strHTML = strHTML & " strHTML = strHTML & " strHTML = strHTML & " strHTML = strHTML & " strHTML = strHTML & " strHTML = strHTML & " Next strHTML = strHTML & ""
""
" & "分区" & " "
" & "容量" & " "
" & "已用" & " "
" & "未用" & " "
" & "空闲" & " "
"
" & DeviceID & " "
" & FormatNumber(intTotalSpace,2,-1,-1,0) & " "
" & FormatNumber(infFuLin,2,-1,-1,0) & " "
" & FormatNumber(intFreeSpace,2,-1,-1,0) & " "
" & FormatPercent(intFreeSpace/intTotalSpace) & " "
DataArea.InnerHTML = strHTML
End Sub
保存为hta文件.
更多信息请查看IT技术专栏