Share via


How to check where a device is located on a portable computer (HTML)

This topic shows you how to find out if an embedded camera or other embedded device is in the front, back, lid, or panel of a portable computer.

Note  The EnclosureLocation property used in this example is only valid for devices that expose this location information in ACPI tables. EnclosureLocation is null if the device does not declare this data in its ACPI table.

 

What you need to know

Technologies

  • Windows Runtime

Prerequisites

You should be familiar with JavaScript and HTML.

Instructions

Using the EnclosureLocation property

The following example function takes a DeviceInformation object and prints out a message about the location of the device.

function locationMessage(deviceInformation)
{
   var locationMessage = "";
   var location = deviceInformation.enclosureLocation;
   if (location == null) {
       return "The device does not specify its enclosure location.";
   }
   if (location.inDock) {
       message = "In docking station.";
   } else if (location.inLid) {
       message = "In lid.";
   } else switch (location.panel) {
       var Panel = Windows.Devices.Enumeration.Panel
       case Panel.unknown:
           locationMessage = "In unknown panel.";
           break;
       case Panel.front:
           locationMessage = "In front panel.";
           break;
       case Panel.back:
           locationMessage = "In back panel.";
           break;
       case Panel.top:
           locationMessage = "In top panel.";
           break;
       case Panel.bottom:
           locationMessage = "In bottom panel.";
           break;
       case Panel.left:
           locationMessage = "In left panel.";
           break;
       case Panel.right:
           locationMessage = "In right panel.";
           break;
       default: 
           locationMessage = "Location unknown.";
           break; 
   } 
   return locationMessage;
}