C++:通过windows函数CreateMutex来禁止双开功能

#include <iostream>
#include <stdlib.h>
#include "myhead1.h"
#include <windows.h>

int main(){
	HANDLE mutex=CreateMutex(NULL,TRUE,"一个全局独有的字符串"); 
	if(mutex && ERROR_ALREADY_EXISTS==GetLastError()){
		printf("客户端已经运行 \n");
	}else{
		printf("客户端第一次运行\n");
	}
	
	system("pause");
	return 0;
}
发布了157 篇原创文章 · 获赞 26 · 访问量 11万+

猜你喜欢

转载自blog.csdn.net/u011624903/article/details/104808673