Just trying to understand windows API :D

Hi, can you tell me if im right :)

1. As far as I know, by using the Windows API it allows us to use the operating systems functions in our programming, am i correct?

2. How exactly does the window.h header file relate to this, wikipedia says it "contains declarations for all of the functions in the Windows API", as far as I can make out the windows.h header file basically IS the Windows API as it contains the functions, am i correct?

Thanks in advance for the help :)
Last edited on
windows.h contains declarations for most of functions in windows API, but not all. It is just a header file after all, to compile/link a windows program still need import library for used functions and corresponding dll's be present at runtime.
So in other words, when you set up your IDE to create a Windows program where you are making calls to various Api functions (some GUI related, others perhaps not), your environment will be set up by the IDE to link statically with kernel32.dll, user32.dll, gdi32.dll, etc. Those files and files they in turn access are the operating system, as it were.
your environment will be set up by the IDE to link statically with kernel32.dll, user32.dll, gdi32.dll, etc.


This is not true, you cannot link statically kernel32.dll, user32.dll, etc ....

This is not true, you cannot link statically kernel32.dll, user32.dll, etc ....


Right. Poor choice of words on my part. I meant the Windows Api functions will be made accessable through implicit linking involving those Dlls.
So, when i go to create a new project in Visual Studio and choose "windows application", the IDE will automatically link my project to the dll files which contain the function declarations of the Windows API, which actually form the Windows API, right or wrong?

Im still abit confused, does the Windows API dll files provide windows functions, or is it the window.h file which provides windows functions?
closed account (3hM2Nwbp)
The DLL files "do the work" while the header files give you an interface through which to use the DLL files.

Edit - If you want to understand the WINAPI then you have a long road ahead of you :P
Last edited on
Haha ok :O

So the dll files contains the declarations for the functions and how exactly does the window.h file contribute to the windows functions :D
closed account (3hM2Nwbp)
The DLL files contain the compiled (binary) implementation - the headers contain the (human readable) declarations.
Last edited on
Ah, so the dll files contain the actual function declarations, but as they are in binary format we need a way of translating this... the windows.h file? that doesnt seem right :S
closed account (3hM2Nwbp)
The DLL files do not contain any declarations, in fact, the function identifiers are purposefully mangled ( http://en.wikipedia.org/wiki/Name_mangling ). You also seem to be mixing the terms "Declaration" and "Definition". ( http://cboard.cprogramming.com/c-programming/122712-variable-declaration-vs-definition.html ) Header files contain only declarations - (and the occasional inline definition).

The mechanics of the linking process is (potentially) beyond the scope of this site, however.
*And incidentally beyond the scope of my knowledge as well.
Last edited on
Ahh, its a wee bit clearer now :)

SO, the windows.h file contains the declarations and the dll files contain the definitions.

Could you explain to me why this is done in two different files, why not just have the definition and declaration in one file, wouldnt it be less hassle?
closed account (3hM2Nwbp)
Well, it's a combination of a lot of reasons really.

1) Separating interface from implementation is what makes up the black-box concept. You shouldn't need to know the inner implementation details in order to use the code.

2) Compilation times are greatly reduced, as constructs using parts of a header do not need to be recompiled for changes made to the implementation.

3) Security - I doubt that Microsoft would want to release the implementation details of their proprietary files for their competitors to pick apart. Not everyone lives in open source hippie land ( zing - sorry :P ).

There are a lot of other reasons as well, Google would be able to tell you more.

Not everyone lives in open source hippie land ( zing - sorry :P ).


That's a 'good in! I like it!
Could you explain to me why this is done in two different files, why not just have the definition and declaration in one file, wouldnt it be less hassle?


The same reason you would separate your own implementations and declarations into header and source files.
Topic archived. No new replies allowed.