更新:2007 年 11 月
在给定 ID 的情况下获取相应的 Device。
命名空间: Microsoft.SmartDevice.Connectivity
程序集: Microsoft.SmartDevice.Connectivity(在 Microsoft.SmartDevice.Connectivity.dll 中)
语法
声明
Public Function GetDevice ( _
deviceId As ObjectId _
) As Device
用法
Dim instance As Platform
Dim deviceId As ObjectId
Dim returnValue As Device
returnValue = instance.GetDevice(deviceId)
public Device GetDevice(
ObjectId deviceId
)
public:
Device^ GetDevice(
ObjectId^ deviceId
)
public function GetDevice(
deviceId : ObjectId
) : Device
参数
deviceId
类型:Microsoft.SmartDevice.Connectivity.ObjectId一个表示设备 ID 的对象。
返回值
类型:Microsoft.SmartDevice.Connectivity.Device
一个表示设备的设备对象。
异常
异常 | 条件 |
---|---|
ArgumentNullException | 当输入参数为 Null 字符串时。 |
DeviceNotFoundException | 当未找到具有给定的设备 ID 的设备时。 |
示例
' Get the default device in the platform, usually an emulator.
Dim device As Device = platform.GetDevice(platform.GetDefaultDeviceId())
' Output information about the device.
Console.WriteLine("Name: " + device.Name + vbCr + vbLf + "Platform: " & _
device.Platform.ToString() + vbCr + vbLf + "ID: " + _
device.Id.ToString())
If device.IsEmulator() Then
Console.WriteLine("Device is an Emulator")
End If
' Output device properties
Console.WriteLine(vbCr + vbLf + "Device Properties:")
Console.WriteLine(" OS_Version: " + device.GetProperty("OS_Version"))
// Get the default device in the platform, usually an emulator.
Device device = platform.GetDevice(platform.GetDefaultDeviceId());
// Output information about the device.
Console.WriteLine("Name: " + device.Name + "\r\n" +
"Platform: " + device.Platform + "\r\n" +
"ID: " + device.Id);
if (device.IsEmulator())
{
Console.WriteLine("Device is an Emulator");
}
// Output device properties
Console.WriteLine("\r\nDevice Properties:");
Console.WriteLine(" OS_Version: " + device.GetProperty("OS_Version"));
权限
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。