O'Reilly logo

.NET Common Language Runtime Unleashed by Kevin Burton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Details of Platform Invoke

To fully use P/Invoke services, you need to understand the concepts of marshaling and callbacks. This section explores each of these topics. Pay particular attention to marshaling because COM Interop uses the same underlying marshaling service as P/Invoke. COM Interop is covered in Chapters 8, “Using COM/COM+ in Managed Code,” and 9, “Using Managed Code as a COM/COM+ Component.”

Note

It would not be practical to show examples from every language throughout this chapter, so the focus has been narrowed to C#. The same features that are shown are available in most languages supported in the .NET Framework.

Declaring the Function: DllImport Attribute

All P/Invoke calls are declared through DllImportAttribute. In its simplest ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required