Can't access USB device inside Windows Store App
Asked Answered
D

1

6

OK, first I shall point that I am completely new to Windows Apps Development, which is good, since I am trying to develop a Windows Store App for PC to use a PrimeSense Scanner connected via USB. I have asked a more specific question about this here.

This time I have a more generic question, which is more related to Windows Store app development. I am using VS2013 Express and compiling for Win32.

When I compile my application for VS2012 and run it as an execcutable file, I can connect to the scanner perfectly. But I can't do the same with VS2013 and running it as a Store app.

I know the device is connected and the drivers are updated and all dlls file placed in the Widnows System 32 directory. I have also added all Capabilities to the App Manifest and also added the following Device Capability

 <m2:DeviceCapability Name="usb">
  <!--OSRFX2 Device-->
  <m2:Device Id="vidpid:1d27 0609">
    <m2:Function Type="classId:ff * *" />
    <m2:Function Type="name:vendorSpecific" />
  </m2:Device>
</m2:DeviceCapability>

The vid and pid, obviously match the corresponding codes of the device.

One of the errors I recieve when trying to conenct to the scanner using OpenNI is:

Could not open to "\\?\usb#vid_1d27&pid_0609&mi_00#7&1601586a&0&0000#{c3b5f022-5a42-1980-1909-ea72095601b1}" USB Device not found

This error is quite frustrating since I know the device is connected. So I tend to think that there is some level os specificity on the Windows Store App side of the game that is not enabling my to connect to the device. As I said, I am compiling for Win32.

Is there a chance that the drivers will not work for a Windows Store App. Is there some extra stuff I should do inside the Windows Store App logic that I am not doing and that is necessary to connect the USB device? I am sorry, but I am completely new to Windows Store App development.

Thank you.

Decrepit answered 23/6, 2014 at 11:59 Comment(2)
Please can you confirm, that your title ask for Windows store app but in the middle you say "VS2013 desktop app will not find the scanner". I am a little confused. Do you mean "VS2013 Store App will not find the scanner"?Exposition
Yes, I meant "VS2013 Store App". Thanks for pointing that out.Decrepit
C
1

You can't do that from metro apps.

You typically create a handle to that usb device by calling CreateFile with that object mananger path as the file to 'create'. CreateFile is not allowed in metro apps - "desktop apps only" - and its 'replacement', CreateFile2, specifically doesn't allow opening object manager objects.

Furthermore, the documentation for CreateFile2 states that in metro apps this function can only open files and directories (and not things like pipes, mailslots, consoles, etc.).

See also this post on social.msdn

Unless I missed something, I don't think this is possible.

Chummy answered 2/7, 2014 at 2:53 Comment(2)
Ok I suppose it's not possible to do that by now... Hope there's a change in the future. thanksDecrepit
@Decrepit - Unfortunately, I don't think this is scheduled to change. Microsoft's model with the metro / windows store apps is a more restricted, 'safer' model. There is potentially one workaround - if you're allowed to install a desktop program along side your metro app, you could have the desktop program handle shuttling data to the usb device from your metro app. But I don't know how you'd distribute that.Chummy

© 2022 - 2024 — McMap. All rights reserved.