Constants and User-Defined Types

In addition to the Declare statement for a DLL function, some functions require you to define constants and types for use with that function. You include constant and user-defined type definitions in the Declarations section of a module, along with the Declare statements for the functions that require them.

How do you know which constants and user-defined types a function requires? Again, you must look at documentation for the function. The Win32API.txt file contains definitions for the constants and user-defined types that accompany the functions it includes. You can use the API Viewer add-in to locate these constants and user-defined types and copy them to paste into your code. Unfortunately, the constants and user-defined types are not associated in any way with the Declare statements that require them, so you still must check the documentation for the DLL function to determine which constants and types go with which Declare statements.

See Also

API Basics | What Is an API? | Why Use VBA to Call the Windows API? | API Resources | Accessing Functions in a DLL | Anatomy of a Declare Statement | Defining Constants for DLL Functions | Creating User-Defined Types for DLL Functions | Understanding Handles