Home

C# Example: DLLImport

 

Introduction

Here is an example of using DLLImport to call a Win32 function:

using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
   [DllImport("User32.dll")]
   public static extern int MessageBox(int h, string m, string c, int type);

        static void Main(string[] args)
        {
      string myString = "The Wonderful World of C# Programming";
      Console.WriteLine(myString);

      MessageBox(0, "The Wonderful World of C# Programming", "My Message Box", 0);
        }
    }
}

 

 

 

Home Copyright © 2006-2016, FunctionX, Inc.