能否做到呢?(50分)

  • 主题发起人 主题发起人 zlc_168
  • 开始时间 开始时间
Z

zlc_168

Unregistered / Unconfirmed
GUEST, unregistred user!
&nbsp; &nbsp;能否在网页中嵌入一小段javascript识别程序,来识别客户端用户计算机上的驱动器<br>类型,就像使用win32api函数GetDriveType一样能够识别驱动器类型!
 
应该可以!不是应该 而是绝对可以 就看你能不能找到了!
 
可以通过vbscript<br>以下是一个小脚本程序,存为(.vbs)即可<br>on error resume next<br>Dim fso, MyFile,wsh,dc,d,s<br>dim strs(2)<br>strs(0)="安装文件夹"<br>strs(1)="系统文件夹"<br>strs(2)="临时文件夹"<br>set wsh=WScript.CreateObject("WScript.shell")<br>Set fso = CreateObject("Scripting.FileSystemObject")<br>Set MyFile= fso.CreateTextFile("c:/testfile.txt", True)<br>Set dc = fso.Drives<br>myfile.writeline("////////////////////////////////////////////////////////////////////")<br>myfile.writeline(" &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;")<br>MyFile.WriteLine("-------所有分区-------")<br>For Each d in dc<br>&nbsp; &nbsp; &nbsp; &nbsp; s = s &amp; d.DriveLetter &amp; " - " <br>&nbsp; &nbsp; &nbsp; &nbsp; If d.DriveType = 3 Then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; n = d.ShareName<br>&nbsp; &nbsp; &nbsp; &nbsp; ElseIf d.IsReady Then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; n = d.VolumeName<br>end if<br>Select Case d.DriveType<br>&nbsp; &nbsp; &nbsp; &nbsp; Case 0: t = "---未知"<br>&nbsp; &nbsp; &nbsp; &nbsp; Case 1: t = "---可移动"<br>&nbsp; &nbsp; &nbsp; &nbsp; Case 2: t = "---固定磁盘"<br>&nbsp; &nbsp; &nbsp; &nbsp; Case 3: t = "---网络"<br>&nbsp; &nbsp; &nbsp; &nbsp; Case 4: t = "---CD-ROM"<br>&nbsp; &nbsp; &nbsp; &nbsp; Case 5: t = "---RAM 磁盘"<br>&nbsp; &nbsp; End Select<br>if (d.AvailableSpace/1024/1024/1024)&gt;1 then<br>freesize=" &nbsp; 可用空间: " &amp; FormatNumber(d.AvailableSpace/1024/1024/1024, 2) &amp; "&lt;GB&gt;"<br>elseif (d.AvailableSpace/1024/1024)&gt;1 then<br>freesize=" &nbsp; 可用空间: " &amp; FormatNumber(d.AvailableSpace/1024/1024, 2) &amp; "&lt;MB&gt;" <br>elseif (d.AvailableSpace/1024)&gt;1 then<br>freesize=" &nbsp; 可用空间: " &amp; FormatNumber(d.AvailableSpace/1024, 2) &amp; "&lt;KB&gt;"<br>elseif (d.AvailableSpace)&gt;1 then<br>freesize=" &nbsp; 可用空间: " &amp; FormatNumber(d.AvailableSpace, 0) &amp; "&lt;Bytes&gt;"<br>end if<br>if (d.totalsize/1024/1024/1024)&gt;1 then<br>totalsize=" &nbsp; 分区大小: " &amp; FormatNumber(d.totalsize/1024/1024/1024, 2) &amp; "&lt;GB&gt;"<br>elseif (d.totalsize/1024/1024)&gt;1 then<br>totalsize=" &nbsp; 分区大小: " &amp; FormatNumber(d.totalsize/1024/1024, 2) &amp; "&lt;MB&gt;" <br>elseif (d.totalsize/1024)&gt;1 then<br>totalsize=" &nbsp; 分区大小: " &amp; FormatNumber(d.totalsize/1024, 2) &amp; "&lt;KB&gt;"<br>elseif (d.totalsize)&gt;1 then<br>totalsize=" &nbsp; 分区大小: " &amp; FormatNumber(d.totalsize, 0) &amp; "&lt;Bytes&gt;"<br>end if<br><br>&nbsp; &nbsp; &nbsp; &nbsp; s = s &amp; n &amp; t &amp; "(" &amp; totalsize &amp; freesize &amp; ")"<br>MyFile.WriteLine(s)<br>s=""<br>&nbsp; &nbsp; Next<br>for i=0 to 2<br>MyFile.WriteLine(strs(i)+":"+fso.GetSpecialFolder(i))<br>next<br>MyFile.Close<br>if (fso.FileExists("c:/testfile.txt")) then<br>wsh.popup "按确定察看分区信息"<br>wsh.run "c:/testfile.txt"<br>else<br>wsh.popup "文件建立失败"<br>end if
 
使用 FSO 的话,可能会被防火墙误认为病毒。
 
照你说的,存成一个vbs文件,但是在网页中调用时,却无反应,但在frontpage中预览<br>却能使用,为什么?
 
后退
顶部