我正在尝试构建一个用于管理MTP设备或Windows手机上的内容的应用。但是,据我所知, Windows.Devices.Portable.StorageDevice 不提供仅列出 MTP设备(或Windows)所需的微调功能电话,因为这些对我来说比较重要,一般MTP设备)。因此,我尝试使用供应商ID(VID)通过 FindAllAsync()设备枚举器命令传递 windows.devices.usb.usbdevices.getdeviceselector() aqs过滤器命令) 0421 和产品ID(PID) 0661 (Windows Phone设备已注册)。这似乎很好,花花公子,直到我试图获取 DeviceInformationCollection 中设备列表中第一个设备的ID,其中一个"访问被拒绝"抛出错误。
现在,根据我最近对此错误的经验,这意味着我还没有在清单中定义适当的功能。我已经定义了:
<Capability Name="videosLibrary" />
<Capability Name="picturesLibrary" />
<Capability Name="musicLibrary" />
<Capability Name="removableStorage" />
<DeviceCapability Name="usb" />
<DeviceCapability Name="6AC27878-A6FA-4155-BA85-F98F491D4F33" />
<DeviceCapability Name="EEC5AD98-8080-425F-922A-DABF3DE3F69A"/>
<DeviceCapability Name="BA0C718F-4DED-49B7-BDD3-FABE28661211" />
<DeviceCapability Name="6BDD1FC6-810F-11D0-BEC7-08002BE2092F" />
<DeviceCapability Name="332ffe6a-af65-41e1-a0af-d3e2627bdf54" />
<DeviceCapability Name="0B9F1048-B94B-DC9A-4ED7-FE4FED3A0DEB" />
<DeviceCapability Name="A5DCBF10-6530-11D2-901F-00C04FB951ED" />
在我的研究中,MSDN表示使用USB我必须使用 classId ,类名称或设备类GUID在USB下定义类类型(的 winUsbId )
<DeviceCapability Name="usb">
<Device Id="vidpid:xxxx xxxx">
<Function Type="classId:xx xx xx"/>
<Function Type="name:xxxxx"/>
<Function Type="winUsbId:xxxxx"/>
</Device>
</DeviceCapability>
但是,他们还指出,在不受支持的课程用法中,海量存储类,我还没有找到可用的WPD或MTP课程。
我在命令上尝试了很多变化,但是每当我尝试查找设备ID时,都会返回此错误。供参考,以下是相关代码:
Enumeration = Windows.Devices.Enumeration;
UsbEnum = Windows.Devices.Usb;
MediaDev = Windows.Devices.Portable;
DeviceInformation = Enumeration.DeviceInformation;
// Get Windows Phones by VID & PID
document.getElementById("Output").innerHTML = ""; // clear output
try {
DeviceInformation.findAllAsync(UsbEnum.UsbDevice.getDeviceSelector("0421", "0661")).then(
//Enumerate Storage Devices using IDs from UsbEnum
successEnum,
errorEnum);
} catch (e) {
document.getElementById("statusMessage").innerHTML = "Failed to enumerate devices, error: " + e.message;
}
function successEnum(winDevice) {
if (winDevice.length) {
var firstDev = null;
try {
firstDev = winDevice.getAt(0).id;
DeviceInformation.findAllAsync(MediaDev.StorageDevice.fromId(firstDev)).then(
successCallback,
errorCallback
)
} catch (e) {
document.getElementById("statusMessage").innerHTML = "Failed to enumerate devices, error: " + e.message;
}
}
}
function successCallback(storageDevice) {
var winPhone = null;
if (storageDevice.length) {
try {
// Get a StorageFolder from the id for the first removable storage device
winPhone = storageDevice.id;
document.getElementById("output").innerHTML = storageDevice.name;
} catch (e) {
document.getElementById("statusMessage").innerHTML = "Error: " + e.message;
}
if (winPhone != null) {
getImageFiles(winPhone);
}
} else {
document.getElementById("output").innerHTML =
"No removable storage devices were found.";
}
}
任何帮助?