+ Reply to Thread
Results 1 to 2 of 2

Thread: How to call DLL function from C#

  1. #1
    Junior Member
    Join Date
    Dec 2011

    How to call DLL function from C#

    Hi All,

    I just want quick example how to call DLL function in C#. I came from Java background and I used to use JNI for DLL calls. Now I'm learning C# and it will be great if someone can show me example. Thanks in advanced!

  2. #2
    Here is an example how to call DLL API function from C#:
    using System;
    using System.Collections.Generic;
    using System.Runtime.InteropServices;  // for dll import
    using System.Linq;
    using System.Text;
    namespace CallDLLExample
        class Program
            // To call a DLL function from C#, you must provide this declaration.
            private static extern int Beep(uint freq, uint duration);
            private static extern int MessageBox(uint handle, string text, string caption, uint type);
            static void Main(string[] args)
                Beep(100, 1000);
                MessageBox(0, "test message", "caption", 48);

+ Reply to Thread

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts