The Windows API
If you look at the Windows System directory,
typically \Windows\System under Window 95/98 and \Winnt\System32 under Windows
NT and XP, you will find a number of Dynamic Link Library (.DLL) files. These
files contain methods that are used to run the operating system and to ensure
a consistent user interface and operating environment. These files make up the
Windows API.
The purpose of the Windows API is to allow you to develop programs consistent
with the Windows operating system and user interface. Instead of individuals
writing the code to create components of the Windows operating system, such as
forms, command buttons, and menus, you can call the appropriate methods in the
Windows API and let the operating system create those components.
The purpose of each method in the Windows API is documented in the Platform
Software Development Kit (SDK). The Platform SDK is shipped with Microsoft
Visual C++ and as part of a subscription to the Microsoft Developer Network
(MSDN.)
As with any other Windows program, Visual Basic uses the methods in the
Windows API. When you perform a task in Visual Basic, such as adding a command
button to a form, Visual Basic calls the appropriate methods to perform the
task. The features of Visual Basic are wrappers to these methods
The reason why you would use the Windows API
is to perform a task beyond what is available from Visual Basic. For example,
you cannot determine or set the cursor blinking rate through any statement,
property, procedure, or method in Visual Basic. You can get the blink rate by
calling the GetCaretBlinkTime method, which returns the cursor blink rate in
milliseconds. If you want to set the cursor to blink at another rate under
specified conditions, you can call the SetCaretBlinkTime method, passing the
specified time in milliseconds.
You can get the same methodality as almost any of the features of Visual Basic
by calling the appropriate Windows API methods. However, calling these
methods directly is typically more complicated and can cause unpredictable
behavior and, if not done correctly, resulting in system errors. For the best
performance and predictable behavior, you should use the intrinsic Visual Basic
methodality.
There are two steps required to call a
Windows API method:
Declare the
method in a module.
Call the method
in your program as you would any other method.