1.CreateMutex()
OpenMutex()
WaitForSingleObject()
ReleaseMutex()
2.进程间互斥通过互斥锁的名称进行
3.如果是服务进程与普通进程进行通信要注意!!!!!!!!!!!!!!!!!!!
HANDLE hNutex = CreateMutex(NULL, FALSE, L"Local\\eee");
HANDLE hNutex = CreateMutex(NULL, FALSE, L"Global\\eee");
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <windows.h>
using namespace std;
class MyClass
{
public:
MyClass(string lockName)
{
name = lockName;
hMutex = OpenMutex(MUTEX_ALL_ACCESS, NULL, name.c_str());
if (hMutex == NULL)
{
hMutex = CreateMutex(NULL, false, name.c_str());
std::cout << "CreateMutex" << "----------" << GetLastError() << std