April 2002
Intermediate to advanced
1024 pages
23h 26m
English
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#.
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", ... |