本文共 442 字,大约阅读时间需要 1 分钟。
2014年3月21日13:50:47
1、使用VS2008创建一个预编译头的控制台项目。
2、源文件内容:
#include "stdafx.h"#include#include using namespace std;int main( void ){ HANDLE hMutex=CreateMutex(NULL,TRUE,L"CenterTransMutex"); if(NULL == hMutex) { printf("CreateMutex error: %d\n", GetLastError()); } else if(GetLastError() == ERROR_ALREADY_EXISTS) { //释放资源 CloseHandle(hMutex);//或结束进程 printf("已经存在\n"); }else { printf("一切正常\n"); } char ch; cin>>ch; return 0;}
转载地址:http://xcwci.baihongyu.com/