Use this tag for questions about importing functions, data or objects from DLLs (Dynamic-link libraries).

Because DLL export table does not contain type information, this information must be provided, to make it possible to use functions, data or objects kept inside DLLs. There are several ways to achieve this.

  • __declspec( dllimport ) is a C and C++ compiler directive. When used in the header file provided by the library, it explicitly defines DLL interface to the client.

  • The System.Runtime.InteropServices.DllImportAttribute class allows managed .NET code to reference a Windows DLL through the magic of Platform Invocation (P/Invoke for short). The System.Runtime.InteropServices namespace contains a wealth of tools to allow .NET to efficiently and effectively use legacy DLLs.