"No exceptional circumstances whatsoever, whether a state of war or a threat of war, internal political instability, or any other public emergency, may be invoked as a justification of torture." -- U.N. Convention Against Torture
What Is The Windows API?
By definition an API (application programming interface) consists of data structures routines, classes, and so on and so forth. These come in handy many a time for programmers. Their are also a lot of hidden aspects of the WindowsAPI. Really experienced coders can reverse engineer .dll's and find functions prototyped and everything. So understanding of the function and it's inner workings comes from sheer hard work. This comes in handy when working with functions that have little or no documentation. However for the most part your best resource is MSDN. I mean, it just doesn't get better than organized lists, does it?
What Can/Should I Do With The Windows API?
You can do about anything with the WindowsAPI. Everything from locating the mouse, to finding information about Windows hidden and visible. You can do some pretty cool things.As I stated earlier the Windows API can save you a lot of time. Of course their are good things and bad things about the Windows API. For larger programs using the Windows API religiously can bog down the efficiency of your code. So for the simpler API functions designing and optimizing
your own functions may be a better idea if you plan to use them frequently. The Windows API also has some overhead you may not want. With all this said you still can't argue with the results
of some of these functions/classes/etc.
How Do I Use MSDN?
Ok, even when I first started programming I was looking to do 'cool' things fast. I mean sure I could count from 1-10, or output asterisk boxes, or maybe even find the area of simple geometric shapes. However I was aware that this was really not that cool. So my search for a way to do 'cool' things led me to a function on MSDN. Now when I first saw this page, it looked quite intimidating. Here is a definition of a random function I chose:
const RECT *prcScroll,
const RECT *prcClip,
So when I first saw this I quickly navigated away and went back to printing numbers on the command line again. This was cool enough for me I guess.. WRONG!! One of the 'scary' things are these data types you have never heard. Like what is an 'HRGN' or an 'HWND'. The answer is simple. These are some datatypes and variables used specifically for the Windows API. Some of them do the same thing as types provided within the C or C++ language. Others aren't included. For understanding these new datatypes check out:
So MSDN is in fact quite intimidating to beginners. The most important thing we have to do is break down the code. You will notice when you scroll down past the definition you will see the actual
function parameters laid out. Even with this it still looks like it is out of your league.
The next important thing is to look at examples of using that function. MSDN most times will have a pretty decent example of how to use it. If this does not work and or the example is not clear to you your next best option is Google. If you don't understand the function I am sure you aren't the first. Actually, I am positive. That is why putting the function's name in Google will yield a plethora of forum posts,tutorials, and more. Another fun option is to use GoogleCode. Please note however, just because it is hosted on google code it
DOES NOT mean the code is used correctly and or in a smart manner. Most times the code is sufficient for an example
or idea of usage.
What Do I Need To Use The Windows API?
For the most part you need (duh) your basic programming environment. A compiler, and editor, or maybe a fully
integrated IDE. In most programs including <windows.h> will be enough. However functions do exist that need
linking to external or other libraries. 9 times out of 10 your compiler or IDE will have the libraries that you want
however they just need to be linked to correctly. A popular example of this is whenever you want to use any of
the WinSock facilities.
In writing this article I am trying to make a complex subject quite a bit easier. In many places if you ask how to use a Windows Function they will point you to the MSDN article and leave it at that. So I am going to make your life quite a bit easier by maintaining a series of articles using a bunch of different functions from the WindowsAPI. In doing so I will make precise, clear examples of usage. I will steer clear or confusing ambiguous code. Hopefully some will find this and my articles to continue useful. So expect a new article very soon on some functions.
Learn | Contribute | Enjoy HTS
Cast your vote on this article 10 - Highest, 1 - Lowest
Comments: Published: 7 comments.
HackThisSite is is the collective work of the HackThisSite staff, licensed under a CC BY-NC license.
We ask that you inform us upon sharing or distributing.