首页 > 建站教程 > JS、jQ、TS >  js读取光驱信息正文

js读取光驱信息

js要读取光驱信息,只能通过ActiveXObject,而且,只能在IE浏览器下。js打开光驱的方法目前没找到:
function getInfo(){
    var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
    var service = locator.ConnectServer(".");
    var properties = service.ExecQuery("SELECT * FROM Win32_CDROMDrive");
    var e = new Enumerator (properties);
    document.write("<table border=1>");
    for (;!e.atEnd();e.moveNext ()){
        var p = e.item ();
        document.write("<tr>");
        document.write("<td>" + p.Caption + "</td>");
        document.write("<td>" + p.Description + "</td>");
        document.write("<td>" + p.Drive + "</td>");
        document.write("<td>" + p.Status + "</td>");
        document.write("<td>" + p.MediaLoaded + "</td>");
        document.write("</tr>");
    }
    document.write("</table>");
}