⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 limitsingleinstance.h

📁 管理项目进度工具的原代码
💻 H
字号:
// LimitSingleInstance.h: interface for the CLimitSingleInstance class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_LIMITSINGLEINSTANCE_H__14CD9485_CDA3_4146_9AB9_B3CDC0C2568B__INCLUDED_)
#define AFX_LIMITSINGLEINSTANCE_H__14CD9485_CDA3_4146_9AB9_B3CDC0C2568B__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

#include <windows.h> 

//this code is from Q243953 in case you lose the article and wonder
//where this code came from...
class CLimitSingleInstance
{
protected:
	DWORD  m_dwLastError;
	HANDLE m_hMutex;
	
public:
	CLimitSingleInstance(TCHAR *strMutexName)
	{
		//be sure to use a name that is unique for this application otherwise
		//two apps may think they are the same if they are using same name for
		//3rd parm to CreateMutex
		m_hMutex = CreateMutex(NULL, FALSE, strMutexName); //do early
		m_dwLastError = GetLastError(); //save for use later...
	}
	
	~CLimitSingleInstance() 
	{
		if (m_hMutex)  //don't forget to close handles...
		{
			CloseHandle(m_hMutex); //do as late as possible
			m_hMutex = NULL; //good habit to be in
		}
	}
	
	BOOL IsAnotherInstanceRunning() 
	{
		return (ERROR_ALREADY_EXISTS == m_dwLastError);
	}
};
#endif // !defined(AFX_LIMITSINGLEINSTANCE_H__14CD9485_CDA3_4146_9AB9_B3CDC0C2568B__INCLUDED_)

⌨️ 快捷键说明

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