Chapter 7. Leveraging Existing Code—P/Invoke

In This Chapter

A quote by Albert Einstein is a good way to start this chapter: “Keep it simple, but not too simple.” In other words, the material should be simple but sufficiently complete to answer the problem. In recent software history, major languages acknowledge their dependency on “legacy” software (“legacy” would refer to the way software was developed before a particular language was introduced) through some method of interoperation. With C++, you called on 'C' functions by specifying the function as extern "C". Java used JNI. Even most flavors of 'C' allowed for __asm constructs so that a programmer could drop down to assembly if he felt so compelled.

With the .NET Framework, a method is available by which you can call legacy C/C++ code, unmanaged code. The first of these methods is known as platform invocation, or P/Invoke. This chapter explains how to call methods and functions that were written before the .NET Framework existed. This chapter shows how the .NET Framework makes working with simple calls into legacy C/C++ code easy and complex calls into legacy C/C++ code doable. Einstein would approve. It is simple for simple cases and can be about as complex as you need it to be.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.152.162