API calls

Dec 1, 2010 at 11:19pm
Hello. I'm a new programmer to C++, but have programmed in javascript, a specialized dialect of basic, and even dabbled in assembly. I've learned how to write a basic console application, and can easily learn the basics. However, I've come across some strange things that I've learned are called APIs. I first discovered them in assembly, and was wondering if they can be used in C++ as well. There are several system dlls that I've found, like kernel32, that contain the commands. If anyone knows how to use them, could they help me out? Also, I was wondering what a good first few programs to write would be. Thanks!
Dec 2, 2010 at 3:09am
APIs in C++ are a bit different. You typically don't communicate with DLLs directly (especially not low level ones like the kernel!)

Instead, the APIs have an interface that offers C or C++ code that you can include in your program. Typically by #including a header, then telling the liker to link to the appropriate lib. You then can use the code in that library as if it were part of your program.

For example on Windows, there is "WinAPI", which is the core API used for making programs on wndows. You can get access to it with #include <windows.h> and it offers tons of functions that you can use.

An alternative (and IMO, a better way to go) is to use external, cross-platform libraries like Qt or wxWidgets (google them). They have different APIs. They use WinAPI underneath when on windows, but when on Mac or Linux they use a different API underneath, so that your program can stay portable.
Dec 2, 2010 at 8:15am
hey man, check this tutorial.
http://www.winprog.org/tutorial/
but you should have a C/C++ background like knowing how to use "switch" and "cases", and how to declare a function and implement it.
Good luck!.
Dec 2, 2010 at 2:49pm
Thanks a bunch!
I got the tutorial for c++ off this site, and it's working well. It's just like basic of javascript. I can see why c++ is such a useful language.
I'm not able to attend any classes on this myself, and have taught myself up from HTML to C++.
Thanks again!
-Ameobea
Topic archived. No new replies allowed.