You cannot do that. Here's the list of issues (ignoring legal issues).
-
Windows.h
varies by OS version. Just because you targeted, say Windows 10, doesn't mean the Window 10.1 or Windows 11 versions won't work either. - Header files are just to make the compiler happy. They don't contain the actual code. To actually link the code you also need the .lib files. Therefore shipping the headers alone isn't sufficient to compile the code anyway.
- Anybody who tries to use your code, especially if they are compiling for Windows, already has the SDK installed anyway. You wouldn't want your, potentially older, copy of
windows.h
to be used in lieu of the more current version. - Even if you did want your version of
windows.h
to be used then you might cause any consuming code to fail to compile as the header wouldn't line up with the .lib they would be importing anyway. This would be very confusing to figure out. -
windows.h
is a wrapper header that includes lots of other header files based upon various preprocessor flags. You'll end up shipping a lot more than just a single header file.
I'm trying to understand why you feel that referencing windows.h
in your code requires that you redist the Windows SDK files at all? If your code is using "Windows" features then that means anybody relying on your code is also going to need Windows dev tools so they'll already have the stuff you are trying to include. Just assume they will have it. For example if you are providing a Visual Studio solution then they are going to need Visual Studio which ships with the Windows stuff already. If you're using cmake instead then they still need the build tools which probably has the Windows files as well.
If you're building a binary (EXE) then nobody needs header files as that is a compile only thing. If you're building a reusable library (DLL) then the only header(s) that are needed are those that define what your code exposes. If you are exposing Windows types then other devs are still going to need the Windows components anyway so you are not actually saving anything.
Unfortunately this is how C++ works and always has. If you don't like the limitations of C++ then you'll need to look at another language. While there has been progress made over the years to make C++ more modular (such as vcpkg or C++ modules) none of these would actually solve your direct problem as Windows (which is C++ agnostic) doesn't provide either of these features (yet).
If you really, really don't want to rely on windows.h
then you could redefine the (hopefully limited) types you do need. But since you cannot control the order in which headers are included (that is up to the cpp file) then you would need to conditionally define them if they weren't already defined. But this still doesn't work around the issue that the .lib files are also needed for any functionality not directly inlined in the header files.