Discovering the API Using Visual Basic 6 and Visual Basic .NET | CodeGuru

Discovering the API Using Visual Basic 6 and Visual Basic .NET

Discovering the API Using Visual Basic 6 and Visual Basic .NET As a Visual Basic programmer, you are likely to encounter the Windows API. This article will explain in detail what the Windows API is, as well as the different implementations of the API in Visual Basic 6 and Visual Basic .NET. Definition of the […]

Written By
CodeGuru Staff
CodeGuru Staff
May 25, 2006
2 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

Discovering the API Using Visual Basic 6 and Visual Basic .NET

As a Visual Basic programmer, you are likely to encounter the Windows API. This article will explain in detail what the Windows API is, as well as the different implementations of the API in Visual Basic 6 and Visual Basic .NET.

Definition of the Windows API

The Windows API is a set of several hundred functions and subroutines that are located in a set of files called Dynamic Link Libraries (DLLs). You can make a function from the Windows API available to your Visual Basic program by declaring the function to be callable from your program. You can then use the Windows API function as you would any built-in Visual Basic function or a function that you have written yourself.

End users cannot access these functions; however, programmers can access the code written in the DLLs through the API and use this code in their programs. This enables you to use existent code in the DLLs and save you time in the programming development cycle. The advantage of using Windows APIs in your code is that they can save development time because they contain dozens of useful functions that are already written and waiting to be used. The disadvantage is that Windows APIs can be difficult to work with and unforgiving when things go wrong.

Advertisement

Windows API Library Files

The Dynamic Link Library (DLL) files that make up the Windows API are commonly located in the Windows SYSTEM subdirectory. These files are found on every PC that is running Windows, so you don’t have to worry about including them if you create a set of setup disks for distribution. The three Windows DLLs are User32.DLL, Kernel32.DLL , and GDI32.DLL.

Several smaller DLLs, known as Extension DLLs, provide functions in addition to those found in the three major DLLs. Some useful extension DLLs include the following:

Advapi32.dll Advanced API services library supporting numerous APIs, including many security and Registry calls
Comdlg32.dll Common dialog API library
Lz32.dll 32-bit compression routines
Mpr.dll Multiple Provider Router library
Netapi32.dll 32-bit Network API library
Shell32.dll 32-bit Shell API library
Version.dll Version library
Winmm.dll Windows multimedia library
Winspool.drv Print spooler interface that contains the print spooler API calls

USER32.DLL

Contains functions that relate to managing the Windows environment, such as:

  1. Handling messages between windows
  2. Managing cursors
  3. Managing menus
  4. Handling other non-display functions

GetCursorPos, SetWindowPos, GetParent, GetActiveWindow, SendMessage

GDI32.DLL

Graphics Device Interface library contains functions that help manage output to different devices, especially the screen.

BitBlt, DeleteObject, RoundRect, SelectObject, StretchBlt

KERNEL32.DLL

Contains functions that manage low-level operating system functions. These include:

  1. Memory Management
  2. Task Management
  3. Resource Handling
  4. File and Directory Handling
  5. Module Management

GetSystemDirectory, GetTempFileName, GetModuleFileName, GetVersionEx

The following pages will explain the usage of the Windows API within Visual Basic 6 and Visual Basic .NET.

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.