|
|
10 of 13 people found the following review helpful:
4.0 out of 5 stars
Excellent but overly complicated and nerdy in parts, 25 Nov 2000
By A Customer
Visual Basic Programmer's Guide to the Windows API by Dan ApplemanWhat is the API exactly? The API is nothing more than a set of libraries. Each library contains a vast number of functions. The beauty of the API, if it has one, is that these functions are added at runtime (dynamic linking) on an as needed basis. Your program doesn't have to store vast amounts of data - the user who buys your program also has these libraries on their own computer. Each dynamically linked library (.dll) can be used by any program on the computer providing that program has been designed to access it. This is where you come in. There are three, no four, steps to becoming an API programmer. Step One: get a good working knowledge of VB, write many programs, discover its limitations (that won't take long), enjoy some late night sessions trying to figure out the Help files, grit your teeth when you find you can't justify text to both edges, when the multimedia control won't function properly, when it takes half an hour to work out the conversion between twips and pixels, etc. etc. You will have some fun, though, and it's surprising what you'll learn. Use the Internet as much as possible, because you can be sure that someone out there has had the same problem as you (these problems themselves are, fortunately, a finite set, just like VB). A little tip: if you do search for something on the Internet be prepared to spend several hours doing so. Be patient, there are thousands of links out there, and one of them has the answer to your problem. Step Two: gradually introduce a few API calls into your programs, start with items such as using the system BEEP, calling a .WAV file, etc. Using the API in this way will get you used to the idea of adding .BAS modules to your program, how to use the Declare statement and how to marry your program's call to the inherent .dll function. Step Three: get Dan Appleman's book and read the first five or six chapters. Understand not only what the API is, what VB really is, what Windows is: all of this and more you will need to know. Understand what a .dll is and what the different system .dll's do. Understand the types of data: on Windows, on VB, in each .dll. Finally, understand how to convert between one data type and another - for example C++ will not recognise VB string types, VB will not deal with unsigned integers, Windows does not understand what a variant (that cornerstone of good but sloppy BASIC programming) is, etc. Step Four: this bit is really important. You won't understand what the API is all at once. So, just read a little every day, try one or two routines here and there, use the Web's vast VB resources for example - C:\WINNT\PROFILES\Administrator\Desktop\TUTORIALS\API Tutorials\Windows API Guide Articles.htm - is a very well written API facility. Don't neglect the theory behind the API, either which, again, is another benefit to be had from using this book. Hold on to the core idea: VB is a puny subset of the API and needs to talk a special, quite complex, and not altogether logical language to get the API to listen. When dealing with Windows bear in mind its more than passing resemblance to a patient forced to take pill No. B to counteract the side-effects of pill No. A. However, pill No. B produces more problems and so pill No. C is needed. By this time the physician realises that pill No. A is no good, and so it's replaced by pill No. D... there's a strong element of this kind of thing in Windows. And just like real doctors, the makers of the Windows family will assure you with a completely straight face that this latest pill No. (read Version No./book/program/operating system) is exactly what you want. Once you've got the basic theory - expounded in the first six chapters of the book you then need to start specialising, and the book has everything for the reader who wants to do this. However, there's one caveat: Appleman is clearly a master programmer - vast understatement of the year, and - like many professionals who have to justify their huge fees and probably like showing off into the bargain - often uses the API when there is no need to do so. A striking example of this is a little app. called TEXTMSGS.VBP in the Chapter 18 folder of the Samples directory that comes with the book. This little app. has approximately 40 Declare statements, countless constants, two .bas modules and a menu thrown in for good measure. Grief, I think I hear you say: what does it do? Fly a man to the moon? No, actually, all it does is tell you the number of lines in a text, the character numbers of the characters selected, the first visible line of the page, etc. In fact next to nothing. The program as written uses vast Windows resources, must have taken ages to write and gives the learner a totally false impression of the difficulties of learning to use the API, and what it's for. In fact I wrote a program that does exactly the same thing, takes 50 lines of code (10 of which are probably not necessary), and does not use the API at all. There isn't a single Declare statement in sight. Dan, you're great, but let's keep our feet on the ground, ok? I'm olsson3@nascr.net. If you want a copy of my 50 line program, e-mail me.
|