This document contains general information about topics relating to this guide. Choose one of the following topics:
In Visual Basic, you can access an API call through the Declare
command. Declare is vaguely similar to the first line in a function or sub definition. You can make the calls Public (accessible everywhere in your program) or Private (only accessible in the form/module/etc. it is Declared in). The Declare command has the following general syntax:
[{Public | Private}] Declare {Function | Sub} call_name Lib DLL_filename [Alias alias_name] ([argument_list]) [As data_type]
The call can be declared as either Public or Private; if omitted, Public is assumed. Function or Sub is used depending on if the call is a function call or a sub call. Next is the name of the function or sub, which is how it will be called in your program. After that is the name of the DLL file that the call is listed in, such as user32.dll or kernel32.dll. The .dll extention can be omitted. Some calls, especially the ones that work with strings, have an alias name that you must include to reference it. Next there is the list of arguments, in var_name As data_type format. Finally, if the call is a function, you include the data type of the return value.
Once you have Declared the call, you can use the function or sub just as you would use any other function or sub in your program. The Declare slightly increases your program size when you compile it, so it's a good idea to only Declare the calls that your program will use.
Some of the calls use data type structures as one or more of the arguments. These must be defined using a Type structure before you Declare the call. Also, a number of the calls put values into some of the parameters passed to the call, especially data type structures.
Each API call entry begins with its Declare command. Just copy this into your code, remove any line breaks that the browser may have included, and that's it. If the call uses data-type structures, you can link to that directly from the Declare (more on that below). Next is a paragraph explaining what the call is used for and any special information you need to know to use it properly. I also tell what the return value of functions is. When I say it is safe to ignore it, the return value is an error code. 0 generally means failure, while 1 means success. If you are careful, you usually won't need to check these values. After that, if applicable, is a table listing and explaining the various parameters. If any of them are changed by the call, it will be noted. Also, some values take what are called flags. Flags are constant values that can often by Or-ed together. They usually set options or settings for the call. You'll find a link to any groups of flags that apply (more on that below). After that is a short example of how the call can be used. Finally, there are links to any related or complementary calls, a link to that call's category, and a link back to the index listing.
I have added listings for many data-type structures in Appendix A of the guide. The entries for these are similar. The definition of the type is at the top, and all of its member values are explained. There are links to all listed calls that use this data type.
In Appendix B are the constants used by the calls, grouped together by purpose. Again, the Const commands defining them are at the top, and each one is explained. Then there are links to any calls that make use of them.
The main index contains a list of all API calls in the guide. There are two separate listings. The first is alphabetical and includes the Appendixes. The second is based on category. The categories group together calls that have the same general purpose, such as working with graphics, INI files, or windows. Note that these groupings are entirely my own, adhere to no standard, and are subject to change. Use these categories to quickly find calls that work with certain aspects of Windows.
Window | A window is the fundamental object in Windows. Not only does this include program windows, but also things such as picture boxes and command buttons. You can tell if a control is a window if it has a .hWnd property (see handles, below). |
Handle | A handle is a Long-type variable that contains a number. This number is the handle to something. The handle references this object. Handles apply to many things, such as windows, files, registry entries, and more. |
Device | A device is an object that supports graphics. This includes the screen, forms, picture boxes, and the printer. You can tell if a control is a device if it has a .hDC property (see device contexts, below). You can draw things on devices. Not every window is a device. |
Device Context | A device context points to a device, like a handle points to an object. Device contexts are also stored in Long-type variables. |
First, the Declares, Types, Consts, and examples (or anything else written in code) will not work. Replace it, if you need to, with similar commands in your own language. The nice thing about Basic is that it is easily readable even if you don't know the language. Secondly, handles and device contexts might not need to be put into Longs. In Visual C++, for example, there are separate data types to hold those. In Visual C++ especially, when using MFC, many member functions of classes are loosely disguised API calls, so this guide also helps you learn about those indirectly. You basically have to remember that the generalities of what the call does and how it is used are the same, but any specific code fragments are invalid.
Paul Kuliniewicz
E-mail: Borg953@aol.com
All material presented on these pages is Copyright © Paul Kuliniewicz, except for other copyrighted material.
http://members.aol.com/Borg953/api/intro.html