应用Drive对象获取所有驱动器信息
本文章将应用Drive对象来获取所有的驱动器信息,可以显示磁盘号,文件系统类型,序列号,总计空间,以及可用空间等.如下图:
具体代码如下,保存为XXX.asp即可.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>应用Drive对象获取所有驱动器信息</title>
</head>
<body>
<%
Set DicObject=Server.CreateObject("Scripting.Dictionary") '应用Dictionary组件将Drive对象的属性及描述写入数组
DicObject.Add "DriveLetter","磁盘号"
DicObject.Add "FileSystem","文件系统类型"
DicObject.Add "SerialNumber","序列号"
DicObject.Add "TotalSize","总计空间"
DicObject.Add "AvailableSpace","可用空间"
Set FSObject=Server.CreateObject("Scripting.FileSystemObject")
Set DriveObject=FSObject.Drives '返回Drives集合
Response.Write "<table width=400>" &vbcrlf
For each key in DriveObject '显示获得的驱动器信息
If key.IsReady Then
For each skey in DicObject
Response.Write "<tr><td width=100 align=left>"&DicObject.Item(skey)&":</td><td width=300 align=left>"&eval("key."&skey)&"</td><tr>"&vbcrlf
Next
Response.Write "<tr><td colspan=2><hr width=300 align=left></td></tr>"&vbcrlf
End If
Next
Response.Write "</table>"
%>
</body>
</html>