CreateMutex (coredll)
Last changed: -64.198.120.1

.
Summary

C# Signature:

[DllImport("coredll.dll", SetLastError=true)]
public static extern int CreateMutex(int lpMutexAttributes, int bInitiaOwner, string lpName);
[DllImport("coredll.dll")]
public static extern int GetLastError();

User-Defined Types:

const long ERROR_ALREADY_EXISTS = 183;

Notes:

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

Sample Code:

    private static bool CheckInstance()
    {        
        CreateMutex(0, 1, "<Application Name>"); // to be replaced by the name of your application
        int lastError = GetLastError();
        if (lastError == ERROR_ALREADY_EXISTS)
        {
        return true;
        }
        return false;
    }

Documentation
CreateMutex on MSDN