locked
File api?

    Question

  • Hi Francisco Martin Garcia,

          

          Sorry for troubling you, I want to ask you a question.

          In my Metro Style APP coded with C++, I want to open a local file,such as c:\myfile.txt or a device object which is created in my driver, such as "\\\\.\\MyMetroDevice", but I don't know what the API is. Is it CreateFile?

     

          Sorry for another question, Where can I find the C++ APIs for Metro Style APPs?  MSDN?

     

    Thanks,

     

    Have a nice day!

     

     

    Monday, January 16, 2012 12:02 PM

Answers

  • Hi Carl,

    Metro style apps run in a sandbox and cannot access all Win32 API. In general there are restrictions on interacting with and altering system behavior. In general, they can only access files in their isolated application data folders. They can get some access to other locations by declaring them in their manifest or when selected by the user via a file picker. See Accessing Data and Files and Using files: accessing, searching, and acting on files for more details.

    I'd strongly recommend reading the documentation on Metro style apps and looking at the //build/ session videos to get an overview of how and why Metro style apps work.

    Most of your app's interaction with the system will be done via the Windows Runtime API, but you can use some Win32 API. The list of Win32 and COM API which can be called from Metro style apps are listed in the documentation at Win32 and COM for Metro style apps. That link also explains how you can look in the SDK header files to see if specific API are in the Desktop or Application families (Desktop family API are not available to Metro style apps). The Windows App Cert Kit will give you a definitive answer as to whether a given function will successfully validate.

    --Rob

    • Marked as answer by Carl Bao Thursday, January 19, 2012 9:20 AM
    Monday, January 16, 2012 4:13 PM
    Owner

All replies

  • Hi Carl,

    Metro style apps run in a sandbox and cannot access all Win32 API. In general there are restrictions on interacting with and altering system behavior. In general, they can only access files in their isolated application data folders. They can get some access to other locations by declaring them in their manifest or when selected by the user via a file picker. See Accessing Data and Files and Using files: accessing, searching, and acting on files for more details.

    I'd strongly recommend reading the documentation on Metro style apps and looking at the //build/ session videos to get an overview of how and why Metro style apps work.

    Most of your app's interaction with the system will be done via the Windows Runtime API, but you can use some Win32 API. The list of Win32 and COM API which can be called from Metro style apps are listed in the documentation at Win32 and COM for Metro style apps. That link also explains how you can look in the SDK header files to see if specific API are in the Desktop or Application families (Desktop family API are not available to Metro style apps). The Windows App Cert Kit will give you a definitive answer as to whether a given function will successfully validate.

    --Rob

    • Marked as answer by Carl Bao Thursday, January 19, 2012 9:20 AM
    Monday, January 16, 2012 4:13 PM
    Owner
  • Hi Rob,

     

    Thanks for your reply.

     

    Your information is so important and seasonable to me. I'm about to studying them.

     

    Best Regards,

     

    Tuesday, January 17, 2012 5:24 AM