Windows API examples with Visual Basic
Introduction
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.
Examples
- 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.
- CD-Player
- 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.
- Display resolution control
- A small tool to display all available screen resolutions, and change between them. The "settings" button opens the original control panel.
- 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.
- 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.
- 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.
- 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!
- 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.
- 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.
- 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.
- 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.
- Window enumeration
- This program enumerated all windows and child windows loaded. The caption and classname of each window is displayed in a treeview control.
- Window properties
- Display the meta information of the selected windows.
- 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.
blog comments powered by Disqus