mfcmutex.c

来自「Samsung公司S3C6400芯片的BSP源码包」· C语言 代码 · 共 78 行

C
78
字号
/*
 * Project Name MFC DRIVER
 * Copyright (c) Samsung Electronics 
 * All right reserved.
 *
 * This software is the confidential and proprietary information
 * of Samsung Electronics  ("Confidential Information").   
 * you shall not disclose such Confidential Information and shall use
 * it only in accordance with the terms of the license agreement
 * you entered into with Samsung Electronics 
 *
 * This file implements MUTEX to gurad MFC multi instance operation..
 *
 * @name MFC DRIVER MODULE Module (MfcMutex.c)
 * @author Shija P S (p.s.shija@samsung.com)
 */

#include <windows.h>

//#include "MfcConfig.h"
#include "MfcMutex.h"


#define  MUTEX_TIMEOUT					5000

static HANDLE hMutex = NULL;


BOOL MFC_Mutex_Create(void)
{
	hMutex = CreateMutex( NULL,                       // default security attributes
	                      FALSE,                      // initially not owned
	                      NULL);                      // unnamed mutex
	if (hMutex == NULL)
		return FALSE;

	return TRUE;
}

void MFC_Mutex_Delete(void)
{
	if (hMutex == NULL)
		return;
	
	CloseHandle(hMutex);
}

BOOL MFC_Mutex_Lock(void)
{
	DWORD  status;

	if (hMutex == NULL)
		return FALSE;

	status = WaitForSingleObject(hMutex, /*MUTEX_TIMEOUT*/ INFINITE);
	if(status != WAIT_OBJECT_0)
		return FALSE;

	return TRUE;
}

BOOL MFC_Mutex_Release(void)
{
	DWORD  status;

	if (hMutex == NULL)
		return FALSE;

	status = ReleaseMutex(hMutex);
	if(status != TRUE) {


	}

	return status;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?