帮忙看看这段代码哪里不对
帮忙看看这段保证只有一个程序实例在运行的代码有什么错误,运行结果不对,已经打开两个实例可还是只显示一个实例在运行
#include <iostream.h>
#include <windows.h>
int main()
{
HANDLE hMutex;
hMutex = CreateMutex(NULL, TRUE, "asd" );
if(hMutex)
{
if(ERROR_ALREADY_EXISTS == GetLastError())
{
cout << "不能同时运行两个实例" << endl;
return 0;
}
cout << "ok现在只有一个实例在运行" << endl;
ReleaseMutex(hMutex);
}
return 0;
}