Access VBA Macro Programming

(Joao Candeias) #1

Chapter 20 API Calls.


Chapter 20 API Calls.


A


lthough the Access object model and VBA code are very comprehensive in
providing you with methods to do various operations on the database, you may
have noticed that there are a number of functions having to do with Windows you
still cannot perform. Even Visual Basic itself does not provide the direct means to do some of
these.
For example, you cannot find the amount of available space on a disk device. You cannot
read the keyboard directly—you can only read incoming keys on a user form, provided
that the form or control has the focus. You cannot determine where the mouse position is.
Obviously, ways of doing these things exist since Windows Explorer can tell you how much
space is on your hard disk and Windows knows which key you pressed. VBA does not have
the direct commands to deal with these subjects, but it does allow access to the WIN32 application
programming interface (API), which in turn allows you to access a treasure chest of information
from Windows directly.
API calls are a very advanced subject and can provide an enormous amount of extra
functionality to your programs. It is not the purpose of this book to go too deeply into API
calls, however, but I will show you some examples of how they can be used to your advantage.


What Is an API Call?


The API (application programming interface) allows you to access the built-in programming
functions from DLL and EXE files, particularly the ones that drive Windows. Other third-party
applications also use DLL files for libraries of functions, and if you are lucky, you may even
be supplied with documentation on how to work the functions.


253

Free download pdf