Partager via


Visual Basic Concepts

Accessing DLLs and the Windows API

When you need capabilities that go beyond the core language and controls provided with Microsoft Visual Basic, you can make direct calls to procedures contained in dynamic-link libraries (DLLs). By calling procedures in DLLs, you can access the thousands of procedures that form the backbone of the Microsoft Windows operating system, as well as routines written in other languages.

As their name suggests, DLLs are libraries of procedures that applications can link to and use at run time rather than link to statically at compile time. This means that the libraries can be updated independently of the application, and many applications can share a single DLL. Microsoft Windows itself is comprised of DLLs, and other applications call the procedures within these libraries to display windows and graphics, manage memory, or perform other tasks. These procedures are sometimes referred to as the Windows API, or application programming interface.

DLLs or Automation?

Another way to bring more power into Visual Basic is through Automation (formerly called OLE Automation). Using Automation is simpler than calling routines in a DLL, and it doesn't create the same level of risk that you'll hit when going straight to the Windows API. By using Automation, you can get programmatic access to a wide range of objects exposed by external applications.

For more information*   For additional information on Automation, see "Programming with Components" in the *Programmer's Guide.

Topics

Using a DLL Procedure in Your Application

An introduction to calling a DLL procedure from within a Visual Basic application.

Accessing the Microsoft Windows API

How to use the API Viewer application to find procedures in the Win32api.txt file.

Declaring a DLL Procedure

An overview of syntax, clauses, and arguments that make up a Declare statement in Visual Basic.

Passing Strings to a DLL Procedure

How to work with String data types in DLL procedures.

Passing Arrays to a DLL Procedure

How to work with arrays in DLL procedures.

Passing User-Defined Types to a DLL Procedure

How to work with user-defined types (structures) in DLL procedures.

Passing Function Pointers to DLL Procedures and Type Libraries

An introduction to using function pointers, callback procedures, and subclassing in Visual Basic.

Passing Other Types of Information to a DLL Procedure

How to work with null values, properties, handles, and variants in DLL procedures.

Converting C Declarations to Visual Basic

A table of data type conversions between the Visual Basic and C languages.