Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't access USB device inside Windows Store App

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.

like image 678
MobileCushion Avatar asked Jun 23 '14 11:06

MobileCushion


1 Answers

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.

like image 60
antiduh Avatar answered Sep 22 '22 17:09

antiduh