Advanced .NET Framework: How To Use the Win32 API
How to use Win32 API functions
Featured Highlights:
This application has four demonstrations of how to use Win32 API calls. Each of
the Win32 API functions and constants have been wrapped up in the Win32API
class for use in each demonstration (Except for Beep calling variations which
is in class CallingVariations):
-
Active processes: This fills a list view with all running Windows processes.
The emphasis of this example is how to use a Win32 callback function,
EnumWindows by using a delegate.
-
Active windows: This fills a listbox with all active visual windows, by
filtering the results of the callback function, EnumWindows using various Win32
API functions. In this example EnumWindows is defined using DllImport instead
of Declare to contrast the difference between using the two methods.
-
Show window: This demonstration allows the user to type in a window caption
and/or class name, and bring the window to the foreground. The emphasis is on
overloading multiple types of parameters to one WinAPI function to allow
passing different types of variables to the function.
-
API Calls: This shows how to use the following miscellaneous Win32 API calls:
GetDiskFreeSpace, GetDiskFreeSpaceEx, GetDriveType, CreateDirectory,
SwapMouseButton, IsPwrHibernateAllowed, SetSuspendState, and Beep examples for
each calling variation. These are examples of calls that returned information
that is not obtainable from managed classes.
Requirements:
Microsoft Visual Studio.NET Professional or greater.
Windows 2000 or Windows XP.
Running the Sample:
Simply press F5.
See Also:
DLLImport Attribute
Declare Statement