📄 17-2 fso的“drives”集合.hta
字号:
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=GB2312" />
<title>17-2 FSO的“Drives”集合</title>
<style>
* { font-size:12px; font-family:宋体, Arial; } /*规定了所有的字体样式*/
body { overflow:auto; }
table { width:100%; }
a { color:blue; line-height:20px; width:100%; overflow:visible; padding:0px 5px; text-decoration:none; }
a:hover { background-color:#EFEFFF; color:black; }
</style>
<script>
function showDriveList(){
var fso, re, n, e, item;
//创建一个FSO对象
fso = new ActiveXObject("Scripting.FileSystemObject");
//将Drives返回的集合转换为枚举对象
e = new Enumerator(fso.Drives);
//初始化返回值
re = "";
//开始循环遍历每个Drive对象
for (; !e.atEnd(); e.moveNext()){
//获取枚举集合中的当前Drive元素
item = e.item();
//获取此驱动器的盘符
re += item.DriveLetter;
re += " - ";
//如果此驱动器为共享驱动器
if(item.DriveType == 3){
//获取其共享名
n = item.ShareName;
}else if(item.IsReady){
//如果驱动器已准备好
//获取驱动器的卷名
n = item.VolumeName;
}else{
n = "[驱动器未准备好]";
}
re += n + "<br>";
}
return(re);
}
document.write(showDriveList());
</script>
</head>
<body>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -