Microsoft Access 2010 Bible

(Rick Simeone) #1

Chapter 27: Using the Windows Application Programming Interface .........................................


941


Common code base


In establishing the Windows API, Microsoft has made a common library of code available to your
Access and Visual Basic applications. You can count on the fact that, if Windows is installed, the
Windows API and its 500-plus functions are available. You don’t have to distribute or check for
these code modules — they exist on every Windows machine. You also know that any time
Microsoft adds functionality to one of its DLLs, that functionality is available to all your
applications.


Tested and proven code


If you develop applications professionally, then you know that time is paramount. Getting your
application to market before a competitor or getting an application up and running in your own
installation can give your company the competitive edge. Every module of code you or your pro-
grammers produce takes time to develop and time to test. The functions included in the API librar-
ies are already tested and proven. They exist on hundreds of thousands — even millions — of
machines all over the world.


A good example is the GetPrivateProfileString function. This function retrieves an entry
from an application’s .ini file. Yes, Access VBA has tremendous string manipulation and file
input/output (I/O) capabilities, but why waste time writing and testing a function to do what
GetPrivateProfileString already does? Let the API take some of the burden off your pro-
gramming staff and allow them to concentrate on more important business issues. As you’ll see in
the “GetPrivateProfileStringA” section, later in this chapter, GetPrivateProfileString is easy
to use — much easier than writing an equivalent function in Access VBA.


Cross-platform compatibility


Microsoft’s strategy for the future of its operating systems includes the convergence of its code
base. All editions of Microsoft Windows use the Win32 API, which makes the applications you
write for one platform portable to others. Almost all Win32 API declarations are available across all
platforms, which gives you an extended user base and keeps you from rewriting much of your
code to fit each kind of installation.


Smaller application footprint


Making use of the DLLs included with Windows keeps you from distributing the same code within
your applications. This, in turn, keeps the size of your applications smaller. Users appreciate the
consideration you put into helping them manage their hardware resources.


Application consistency


Users are familiar with common dialog boxes, such as the File Find, and font selection dialog
boxes. These dialog boxes are actually displayed by API functions and are available to any applica-
tion needing the resources provided by these dialog boxes. The Windows API provides your

Free download pdf