The classWin32APIis defined in a separate file, Win32API.vb. Each API declaration, using theDeclare Statement, is available as aSharedmember of theWin32APIclass. Shared members can be called directly using the class name. It is not necessary to create an instance of the class to use them.
The main form contains a tab control with four tab pages. Each tab page demonstrates an action using Win32 API calls:
- Active ProcessesFills a list view with all running Windows processes. The emphasis is on how to use a Win32 callback function,EnumWindows, by using a delegate.
- Active WindowsFills aListBoxcontrol with all active windows, by filtering the results of the callback function,EnumWindows, using the Win32 API. In this exampleEnumWindows is defined using theDllImportAttributeclass instead of theDeclare Statementto contrast the difference between using the two methods.
- Show WindowAllows the user to type a window caption and/or class name and bring the window to the foreground. This example emphasizes overloading multiple types of parameters to one Win32 API function to allow passing different types of variables to the function.
- API CallsShows how to use the following Win32 API calls:GetDiskFreeSpace,GetDiskFreeSpaceEx,GetDriveType,CreateDirectory,SwapMouseButton,IsPwrHibernateAllowed,SetSuspendState, andBeep. These are examples of calls that return information that is not obtainable from the managed-class equivalents.