The following example shows how a DLL can be imported and called in
c sharp. It calls MessageBeep (which is a Win32 API function).
MessageBeep is found in user32.dll.
using System;
using System.Runtime.InteropServices;
class ImportDll {
static void Main() {
MessageBeep(BeepType.IconExclamation);
}
[DllImport("user32.dll")]
public static extern bool MessageBeep(BeepType beepType);
public enum BeepType {
SimpleBeep = -1,
IconAsterisk = 0x00000040,
IconExclamation = 0x00000030,
IconHand = 0x00000010,
IconQuestion = 0x00000020,
OK = 0x00000000
}
}