Windows dynamic-link libraries (DLLs) represent a special category of interoperability. Windows APIs do not use managed code, do not have built-in type libraries, and use data types that are different than those used with Visual Studio .NET. Because of these differences, and because Windows APIs are not COM objects, interoperability with Windows APIs and the .NET Platform is performed using platform invoke, or PInvoke. Platform invoke is a service that enables managed code to call unmanaged functions implemented in DLLs. You can use PInvoke in Visual Basic .NET by using either the Declare statement or applying the DllImport attribute to an empty procedure.
To find a walkthrough of calling the Win32 API, see the topic "Walkthrough: Calling Windows APIs" under COM Interop in the MSDN help.
This was first published in August 2002