如何检查设备是否位于便携式计算机上 (HTML)
[ 本文适用于编写 Windows 运行时应用的 Windows 8.x 和 Windows Phone 8.x 开发人员。如果你要针对 Windows 10 进行开发,请参阅 最新文档 ]
本主题介绍如何查明嵌入式相机或其他嵌入式设备是在便携式计算机的前面、后面、盖还是面板中。
注意 此示例中使用的 EnclosureLocation 属性仅对于在 ACPI 表中公开此位置信息的设备用效。如果设备未在其 ACPI 表中声明此数据,则 EnclosureLocation 为空。
你需要了解的内容
技术
- Windows Runtime
先决条件
你应该熟悉 JavaScript 和 HTML。
说明
使用 EnclosureLocation 属性
以下示例函数采用 DeviceInformation 对象并输出一条关于设备位置的消息。
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;
}