Skip to Content
.NET Common Language Runtime Unleashed
book

.NET Common Language Runtime Unleashed

by Kevin Burton
April 2002
Intermediate to advanced content levelIntermediate to advanced
1024 pages
23h 26m
English
Sams
Content preview from .NET Common Language Runtime Unleashed

Platform Invoke Overview

A large investment has been made in ensuring that unmanaged code is a full participant. For most cases, it is simple to seamlessly interoperate with legacy code. Listings 7.1 through 7.4 show how to interoperate with MessageBox in some of the languages that are supported under the .NET Framework.

Listing 7.1 shows how to set up a call to the legacy code in the user32.dll from C#.

Listing 7.1. Message Box Interaction from C#
 using System; using System.Runtime.InteropServices; public class Win32 { [DllImport("user32.dll", CharSet=CharSet.Auto)] public static extern int MessageBox(int hWnd, String text, String caption, uint type); } public class HelloWorld { public static void Main() { Win32.MessageBox(0, "Hello World", ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Customizing the Microsoft® .NET Framework Common Language Runtime

Customizing the Microsoft® .NET Framework Common Language Runtime

Steven Pratschner

Publisher Resources

ISBN: 0672321246Purchase book