我正在制作一个Windows商店设备应用,以便在我的设备插入时进入自动播放,但是当我尝试访问应用中的任何数据时,我不断获得deniedBySystem
而我是不确定如何访问我的设备。
private async void OpenDevice()
{
UInt32 vid = 1234;/*stand in vid and pid not real ones i use in my code*/
UInt32 pid = 5678;
lstResults.Items.Clear();
string aqs = UsbDevice.GetDeviceSelector(vid, pid);
int counter = 0;
var myDevices = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync();
//var myDevices = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(aqs); /*I was using this but it wasn't returning any device*/
for (int i = 0; i < myDevices.Count; i++)
{
try
{
if (myDevices[i].Id[4] == 'U' && myDevices[i].Id[8] == 'V' && myDevices[i].Id.Substring(12, 4) == vid.ToString())/* this if statements makes it so I only get the device I want*/
{
lstResults.Items.Add("VID " + myDevices[i].Id.Substring(12, 4) +
" PID " + myDevices[i].Id.Substring(21, 4));
counter++;
var deciceAccessInfo = Windows.Devices.Enumeration.DeviceAccessInformation.CreateFromId(myDevices[i].Id);
lstResults.Items.Add(deciceAccessInfo.CurrentStatus.ToString()); // this line informs me access is denied
// lstResults.Items.Add(myDevices[i].Id);
var usbDevice = await UsbDevice.FromIdAsync(myDevices[i].Id);//this line returns usbDevice to equal null
}
}
catch (Exception exception)
{
lstResults.Items.Add(exception.Message.ToString());
}
}
lstResults.Items.Add(counter + " out of " + myDevices.Count + " Have the correct VID");
}
在Package.appxmanifest
我检查了所有功能,以防其中一个拒绝我访问,但事实并非如此。我也尝试以管理员身份运行该程序,看看是否能让我访问,但没有快乐。所以我的问题是什么让我无法访问并且有办法绕过它吗?