locked
Device Control(CreateDeviceAccessInstance)

    Question

  • Hi All,I Created a metro app using C++.I want to control some device.Then I find an API from win32_and_com+.

    ICreateDeviceAccessAsync *deviceAccessAsync=nullptr;
    void *pResult=nullptr;
    LPCWSTR path=L"";  
    CreateDeviceAccessInstance(IID_IDeviceIoControl,path,GENERIC_READ,&deviceAccessAsync);
    
    deviceAccessAsync->AddRef();
    deviceAccessAsync->Start();
    deviceAccessAsync->Wait(10000);
    deviceAccessAsync ->GetResult(&pResult);
    deviceAccessAsync->Close();
    deviceAccessAsync->Release();
    

    then goto the function "eAccessAsync ->GetResult(&pResult)",it returns Access is denied,
     How do I can?

    The other is the  pReslt  how to use?I think it can be a IDeviceIoControl?

    Wednesday, December 21, 2011 8:38 AM

Answers

All replies

  • Damon,

     

    This sample demonstrates how to do this:

     

    http://code.msdn.microsoft.com/windowsapps/MoFx2App-Sample-510e3755

     

    Which device are you developing for?

     

    Best Wishes - Eric

    Wednesday, December 21, 2011 6:23 PM
    Moderator
  • Hi Eric,

    Thanks for your answer.

    This demo works as I expected, but  the reason of the Access is denied can't find, maybe I need higher UAC level?

    But my visual studio can't work when changed the UAC level,Why?

    I want to control BT,Wifi,USB etc.

    Thursday, December 22, 2011 2:23 AM
  • Hi Eric,

    I also encountered this Access Denied problem in my Metro style app with my customer driver.

    I followed the rules that you mentioned in other thread as below.

    1. Ensure that the driver inf has the property key set to enable access to metro applications. Look at the OSRUSBFX2 sample INF for information on how to set this property key.

    2. The device metadata has been authored for the device and it has been loaded into the system.

    3. The device metadata has the right information notably the PrivilegedApplications section

    4. The application manifest as the interface guid declared as a DeviceCapability

    I also have questions about this requirements. How my device metadata can be authored or get signature for device? Because Metro style app tries to access customer driver, what DeviceCapability should be declared in app manifest?

    My custom driver is a filter driver of system device such as controller filter. It doesn't showed in Device State after I loaded the device metadata of system device into system, even I press F5 or reboot system. Does Windows 8 can support Metro style apps access to customer (filter) driver of internal device?

    Thank you.

    Wednesday, January 04, 2012 2:47 AM
  • Does Windows 8 can support Metro style apps access to customer (filter) driver of internal device?


    Mike,

    This is not supported.

    Best Wishes - Eric

    Saturday, January 07, 2012 1:51 AM
    Moderator
  • Hi Eric,

    Thanks for your answer.

    This demo works as I expected, but  the reason of the Access is denied can't find, maybe I need higher UAC level?

    But my visual studio can't work when changed the UAC level,Why?

    I want to control BT,Wifi,USB etc.

    Damon,

    Lets start with one driver.  What type of USB device do you have and what driver have you written for it? 

    Best Wishes - Eric

    Saturday, January 07, 2012 1:55 AM
    Moderator
  • This is not supported.

    Best Wishes - Eric

    Eric, 

    Do you mean that Metro style apps can't access any driver of non-removeable device in the current Windows 8 preview version? This will a big problem that we can't migrate our desktop app to Metro style app with our filter driver in our future projects. Does Microsoft have any plan for this problem?

    Thank you.

    Mike

    Tuesday, January 10, 2012 9:49 AM
  • Hello Eric,

    I am able to communicate (sending IOCTLs) to my own WIN driver (on WIN7 and WIN8) using my NON-metro UI App (legacy app). I just had to do the "CreateFile" and the "DeviceIoControl" calls. However, by looking at the "MoFx2App-Sample" example, I understand that we need to use the CreateDeviceAccessInstance() API and the DeviceIoControlSync() API for all the METRO Apps.

    While doing this for an metro-app, I am having an issue in finding out the "LPCWSTR deviceInterfacePath" for my device, which needs to be supplied as the 2nd argument for the CreateDeviceAccessInstance() API. I came accross things like - Device Instance Path, Hardware IDS, GUID ..... But, none of them are helping me to call the CreateDeviceAccessInstance() API successfully. Could you please let me know where I can find the "deviceInterfacePath" for a WIN Device ? Thanks a lot !!

    Regards,

    Shreyas

    Wednesday, January 11, 2012 7:25 PM
  • I assume that your custom driver has a unique device interface class GUID. If not please make sure to have one.

     

    For metro style applications, you would use the windows.devices.enumeration API to enumerate devices of a specific class guid. The MoFx2App sample shows how you do this. Look in the JavaScript file. The API will return a collection of DeviceInformation objects that match the class guid. Thus if you had three of your devices, you would see three instances.  There is a property in the DeviceInformation object called the id. This returns a string. This is the device path that needs to be passed to the CreateDeviceAccessInstance API.

    Thursday, January 12, 2012 12:51 AM
  • This is not supported.

    Best Wishes - Eric

    Eric, 

    Do you mean that Metro style apps can't access any driver of non-removeable device in the current Windows 8 preview version? This will a big problem that we can't migrate our desktop app to Metro style app with our filter driver in our future projects. Does Microsoft have any plan for this problem?

    Thank you.

    Mike

    Does anyone can answer this quesiton? thanks.
    • Edited by Mike_Wu Tuesday, January 17, 2012 8:47 AM
    Tuesday, January 17, 2012 8:06 AM
  • We will have more information available sometime after the Consumer Preview releases.

    Tuesday, January 31, 2012 7:59 PM
    Moderator
  • This is not supported.

    Best Wishes - Eric

    Eric, 

    Do you mean that Metro style apps can't access any driver of non-removeable device in the current Windows 8 preview version? This will a big problem that we can't migrate our desktop app to Metro style app with our filter driver in our future projects. Does Microsoft have any plan for this problem?

    Thank you.

    Mike

    Does anyone can answer this quesiton? thanks.


    Up crazily!

    I want to know this answer too.  Because I'm testing the communications between Metro style app and a hardware disk filter driver, such as sending IOCTLs. But I always get E_ACCESSDENIED error from the GetResult routine.


    Up crazily!

    Up crazily!

    Up crazily!
    Saturday, February 04, 2012 2:13 AM