Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SimpleDirect2DApplication fails to compile - identifier FILE_INFO_BY_HANDLE_CLASS is undefined #317

Open
rnikander opened this issue Nov 18, 2023 · 2 comments

Comments

@rnikander
Copy link

I downloaded Visual Studio and have been trying some of these samples. This application did not compile.

The error is pointing to line 1065 of fileapi.h.

WINBASEAPI
BOOL
WINAPI
SetFileInformationByHandle(
    _In_ HANDLE hFile,
    _In_ FILE_INFO_BY_HANDLE_CLASS FileInformationClass,   // Error here
    _In_reads_bytes_(dwBufferSize) LPVOID lpFileInformation,
    _In_ DWORD dwBufferSize
    );

I'm running on Windows 11 Home.

@rnikander
Copy link
Author

Same error with "SimplePathAnimationSample".

@koal44
Copy link

koal44 commented Dec 10, 2023

Ran int the same problem when trying to run SimpleDirect2dApplication. The problem is that the current sdkddkver.h is bugged. Let's review.
FILE_INFO_BY_HANDLE_CLASS is only defined when:

// minwinbase.h
#if (NTDDI_VERSION >= NTDDI_LONGHORN)
typedef enum _FILE_INFO_BY_HANDLE_CLASS {
...
} FILE_INFO_BY_HANDLE_CLASS, *PFILE_INFO_BY_HANDLE_CLASS;
#endif

NTDDI_VERSION is defined in sdkddkver.h, and here's the problematic code:

// sdkddkver.h
#ifndef NTDDI_VERSION
   #ifdef _WIN32_WINNT
      #if (_WIN32_WINNT <= _WIN32_WINNT_WINBLUE)
         #define NTDDI_VERSION   NTDDI_VERSION_FROM_WIN32_WINNT(_WIN32_WINNT)
      #elif (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
         #define NTDDI_VERSION   WDK_NTDDI_VERSION
      #endif
   #else
      #define NTDDI_VERSION   0x0A00000C
   #endif
#endif

If _WIN32_WINNT_WINBLUE < _WIN32_WINNT < _WIN32_WINNT_WIN10, then NTDDI_VERSION remains undefined, leading to the original error. This will occur if you run the app as is, with 0x0603 < 0x0700 < 0x0A00.

A temporary fix is to place one of these directives at the beginning of your app header:

//#define NTDDI_VERSION 0x07000000
//#define _WIN32_WINNT 0x0A00

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants