What is "pinvoke"

P/Invoke means Platform Invocation Services. It is a specification created by Microsoft to provide interoperability with unmanaged managed application code. Data transmitted to/from P/Invoke should normally be converted to/from CLI types before it can be used. This process is called packaging.

The wiki site for P/Invoke method statements is pinvoke.net.

The base namespace of . NET Framework is System.Runtime.Interopservices .

Example code in C # of a class using P/Invoke (from pinvoke.net):

class Beeper
{
    public enum beepType
    {
        SimpleBeep  = -1,
        OK    = 0x00,
        Question  = 0x20,
        Exclamation  = 0x30,
        Asterisk  = 0x40,
    }

    [DllImport("User32.dll", ExactSpelling=true)]
    private static extern bool MessageBeep(uint type);

    static void Main(string[] args)
    {
        Class1.beep(beepType.Asterisk);
        Thread.Sleep(1000);
        Class1.beep(beepType.Exclamation);
        Thread.Sleep(1000);
        Class1.beep(beepType.OK);
        Thread.Sleep(1000);
        Class1.beep(beepType.Question);
        Thread.Sleep(1000);
        Class1.beep(beepType.SimpleBeep);
    }

    public static void beep(beepType type)
    {
        MessageBeep((uint)type);
    }
}