ATL Library and Windows Store apps

Just a quick post in case you run up against this issue.

You can use a subset of ATL Library code in your Windows Store app.  You may run into errors with validation when compiling or when running the Windows App Certification Kit (WACK) tool.

If you include CComCriticalSection in your Windows Store app code and then run the WACK tool you will get these errors:

Error Found: The supported APIs test detected the following errors:

  • API GetModuleHandleW in kernel32.dll is not supported for this application type. XXXXX.XXX calls this API.
  • API InitializeCriticalSectionAndSpinCount in kernel32.dll is not supported for this application type. XXXXX.XXX calls this API.

This is caused by a bug in the current ATL Library.  The workaround is to add this code to your project which will implement the correct code (add it to any of your CPP files):

#if (_ATL_NTDDI_MIN >= NTDDI_VISTA)

namespace ATL {

BOOL _AtlInitializeCriticalSectionEx(__out LPCRITICAL_SECTION lpCriticalSection, __in DWORD dwSpinCount, __in DWORD Flags)
{
return InitializeCriticalSectionEx(lpCriticalSection, dwSpinCount, Flags);
}

}
#endif

Let me know if this helped you out!

-Jeff