locked
Are there any restrictions of using C Runtime library in Metro Style apps or WinRT DLL?

    Question

  • I am porting the existing code that relying on C Runtime library such as file, string, etc to the Metro Style Apps and WinRT DLL. Are there any restrictions of using it? Is it portable to other platforms such as ARM?

    Thanks.

    Friday, November 11, 2011 6:57 AM

Answers

  • Most of the functions in CRT are available for Metro style apps.  Those that are not available will be aytomatically hidden by the appropriate macros (WINAPI_FAMILY etc.).  However, I must mention that most of the files API will work only in specific locations where Windows allows access to apps.  CRT API will work within the boundaries that Windows has for accessing OS resources (like files, directories, settings, handles etc.) at runtime.

    Thanks


    Raman Sharma | Program Manager, Visual C++ | @rasharm_msft

    (if my post has answered your question, please consider using the 'mark as answer' feature in the forums to help others)
    • Marked as answer by petert2011 Friday, November 11, 2011 7:44 PM
    Friday, November 11, 2011 7:20 PM

All replies

  • Most of the functions in CRT are available for Metro style apps.  Those that are not available will be aytomatically hidden by the appropriate macros (WINAPI_FAMILY etc.).  However, I must mention that most of the files API will work only in specific locations where Windows allows access to apps.  CRT API will work within the boundaries that Windows has for accessing OS resources (like files, directories, settings, handles etc.) at runtime.

    Thanks


    Raman Sharma | Program Manager, Visual C++ | @rasharm_msft

    (if my post has answered your question, please consider using the 'mark as answer' feature in the forums to help others)
    • Marked as answer by petert2011 Friday, November 11, 2011 7:44 PM
    Friday, November 11, 2011 7:20 PM
  • You say "most".  And I do see the API family partition macros in the CRT headers.  However, I don't understand why it seems like some functions in CRT (e.g. _beginthreadex) are allowed but the equivalent Win32 APIs are not.  It seems like CRT gives more power than underlying Win32 API on Metro.   After all, _beginthreadex just calls CreateThread (which is a forbidden API when called from Metro).  But _beginthreadex is just fine for windows store app validation. 

    Can I rely on this difference in RTM? There are a lot of things in CRT that I want to take advantage of, e.g. open, fopen etc that call forbidden Win32 APIs, but since they're part of the CRT and you're saying that you're supporting the CRT (with functions that are in the right family) then they should be allowed.

    Saturday, April 28, 2012 9:05 PM