+ Reply to Thread
Results 1 to 2 of 2

Thread: Finding Hardware Information

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    35

    Finding Hardware Information

    How to list the information of all on-board devices using JavaScript , any idea how it works ? thanks in advance .

  2. #2
    Junior Member
    Join Date
    Jan 2012
    Posts
    41
    let us develop a simple (JavaScript) which shows the technique for retrieving the information of each on-board device on a web page. The entire code for the sample is as follows:
    Code:
    <!DOCTYPE  HTML  PUBLIC  "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
          <head>
                <title></title>
                <meta  name="GENERATOR"  content="Microsoft Visual Studio .NET
    7.1">
                <meta  name="vs_targetSchema"
     content="http://schemas.microsoft.com/intellisense/ie5">
          <script  id=clientEventHandlersJS  language=javascript>
    <!--
    
    function Button1_onclick() {
          var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
          var service = locator.ConnectServer(".");
          var properties = service.ExecQuery("SELECT * FROM
    Win32_OnBoardDevice");
          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.Description + "</td>");
                document.write("<td>" + p.DeviceType + "</td>");
                document.write("<td>" + p.Enabled + "</td>");
                document.write("<td>" + p.Tag + "</td>");
                document.write("</tr>");
          }
          document.write("</table>");
    }
    
    //-->
    </script>
    </head>
          <body>
                <INPUT  id="Button1"  type="button"  value="Button"
     name="Button1"  language=javascript  onclick="return Button1_onclick()">
          </body>
    </html>
    The above code would automatically list all the devices (which are part of hardware) along with their descriptions, device types and other information. To retrieve device information, I used the built-in class “Win32_OnBoardDevice.” The class internally has a lot of properties, methods and events. But, in the above example we concentrated only on the properties “Description,” “DeviceType,” “Enabled” and “Tag” (related to “Win32_OnBoardDevice” class).

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts