Windows API examples with Visual Basic


The following examples show how you can access Windows API functions from Visual Basic. The techniques used in these examples are explained in the Accessing the Windows API with Visual Basic articles.

Just to let you know...
Each example includes the full source code, and a working executable. You are free to use the code in your own software if you include the copyright information.


Text box auto-completion
Using Internet Explorer 5.0 DLL's, user input can be autocompeted. The code works for both comboboxes and normal textboxes. It features an Internet Explorer version check and the auto-completion module code. Auto-completion on a Visual Basic combobox.
A CD Player sample using MCI API functions, having all basic functions for a player application. The code is written in a nice class you can embed in your own software. A CD-Player application.
Display resolution control
A small tool to display all available screen resolutions, and change between them. The "settings" button opens the original control panel. Changing the screen resolution.
File-related functions
This sample explains how a special folder location can be obtained, INI files can be manipulated and how to create a temporary file. Handling special folder locations, INI files and temporary files.
File finder
A powerfull example for finding files. The code is much more efficient then Visual Basic's own internal functions. It allows you to search for files at all drives, recursive through all folders, and using very little memory (it doesn't store an array of files, but triggers an event notification for each file). The classes provided are easy to implement in your own software. Find files fast using the Windows API.
Font enumerator
This program does a simple enumeration on all your system fonts. It's also able to extract the font name from a TTF file. Enumerate all fonts installed at your system.
API enumerator
A little tool to enumerate the API's from a DLL file. Unfortunately, the API functions this tool uses have become deprecated or unmaintained. The example doesn't work with newer versions of Windows, you're encouraged to fix this example! Enumerate API's available in a given DLL file.
Keyboard light show
This application is able to read your keyboard status, and change it too. This has all the ingredients for a nice keyboard light show. The numlock, capslock and scrolllock keys light up when the application sets them. A keyboard lightshow demo The numlock and capslock keys enabled by the demo.
Mouse trap
Even your own mouse can't escape from the Windows API. This digital mouse trap proves that. It moves the mouse to the trap, and clips the mouse cursor afterwards. A digital mouse trap.
System information
The screenshot says it call, this application extracts all kinds of information about your system. It displays the windows version, memory usage, disk information, login information, and system colors. A panel with general information about your system.
System-tray control
This application includes a custom "UserControl" to insert an icon in the system tray. The system tray settings are changed by setting the representive properties of the UserControl. Systray events are reported back as event notifications to the parent form. The control is easy to embed in your own application. An application icon in the system tray.
Window enumeration
This program enumerated all windows and child windows loaded. The caption and classname of each window is displayed in a treeview control. A list of all root and child windows.
Window properties
Display the meta information of the selected windows. The meta information of a window.
Window style changer
Every window has style bits. When you change them, the window behavour or appearance will change. It updates the style of a picturebox, to change it a top level window. The window style changer appearance.

blog comments powered by Disqus