This chapter has introduced the Platform Invoke mechanism, which .NET provides to let .NET code call unmanaged functions in DLLs.
Platform Invoke can be used from all .NET languages using the DllImport attribute, and you have seen examples of how to do this in Visual Basic .NET, Visual C#, and managed C++. Visual Basic .NET also offers the Declare statement as a front end to Platform Invoke, which emulates the Visual Basic 6.0 Declare construct. Managed C++ code can use the It Just Works mechanism, which allows C++ developers to call unmanaged functions simply by including header files and linking with the appropriate libraries.
The basics of Platform Invoke presented in this chapter will let you work with a large number of unmanaged functions. Chapter 13 discusses more advanced aspects of interoperability.