createmutex (coredll)
Last changed: -64.198.120.1

.
Summary

C# Signature:

[DllImport("coredll.dll", SetLastError=true)]
public static extern int CreateMutex(IntPtr lpMutexAttributes, bool bInitiaOwner, string lpName);
// Not needed due to using the SetLastError=true
// use Marshal.GetLastWin32Error() to retrieve the error.
//[DllImport("coredll.dll")]
//public static extern int GetLastError();

User-Defined Types:

const int ERROR_ALREADY_EXISTS = 183;

Notes:

It should be used in conjunction with Marshal.GetLastWin32Error() to check the application already existed in the process list.

Sample Code:

    private static bool CheckInstance()
    {        
        CreateMutex(IntPtr.Zero, true, "<Application Name>"); // to be replaced by the name of your application

        return Marshal.GetLastWin32Error() == ERROR_ALREADY_EXISTS;
    }

Documentation
CreateMutex on MSDN