CreateFile2 doesn't work in windows 7

Jan 13, 2013 at 7:13 AM

I am trying to add the latest download to my project but it doesnt work because of the following code.



ScopedHandle hFile( safe_handle( CreateFile2( fileName,                                                  GENERIC_READ,                                                  FILE_SHARE_READ,                                                  OPEN_EXISTING,                                                  nullptr ) ) );


It is in the function "LoadTextureDataFromFile", If I make sure CreateFile2 isnt compile then I can run my application.


This is on windows 7 VS 2012.

Jan 14, 2013 at 12:42 AM
Edited Jan 14, 2013 at 12:46 AM

By default, VS 2012 and the Windows 8.0 SDK assumes you are building for Windows 8 APIs, not 'down-level'.  For Windows Store apps this is a safe assumption. For Win32 desktop apps, you need to explicitly build your project for down-level compatibility by setting the _WIN32_WINNT preprocessor value to 0x0601 (Windows 7) or 0x0600 (Windows Vista)

If you use the DirectXTex_Desktop_2012 project, that value is already set for the DirectXTex library. Therefore I assume you are using the DDSTextureLoader standalone module. If you were using the DIrectXTK library version along with the DirectXTK_Desktop_2012 project, then the value would be set there as well.