// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
//create mutex
HANDLE m_hMutex; //全局
CString strClassName= "helloworld";
m_hMutex=OpenMutex(MUTEX_ALL_ACCESS,FALSE,strClassName);
if (m_hMutex==NULL)
{//表示没有其它实例在运行.创建
m_hMutex=CreateMutex(NULL,TRUE,strClassName);
}else
{//表示已经有一个实例在运行
AfxMessageBox( "已经在运行了 ",MB_OK,MB_ICONEXCLAMATION);
//结束程序
return FALSE;
}
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}