如何检测进程中某一程序是否运行

怎么检测进程中某一程序是否运行?
怎么检测进程中某一程序是否运行?比如打开某一exe程序的时候,检查已经运行的话就不再打开了。

------解决方案--------------------
String strFileName;
char szBuf[256];

bool bFound(false);

::PROCESSENTRY32 pe32 = {sizeof(pe32)};
HANDLE hSnapShot = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (hSnapShot == NULL)
return bFound;

try
{
bool bFlag = ::Process32First(hSnapShot, &pe32);
while (bFlag)
{
strFileName = String(pe32.szExeFile);
if (strFileName.Pos("\\") != 0)
strFileName = ExtractFileName(strFileName);
if (SameText(strFileName, strExeFile))
{
bFound = true;
break;
}
bFlag = ::Process32Next(hSnapShot, &pe32);
}
}
__finally
{
::CloseHandle(hSnapShot);
}

return bFound;
------解决方案--------------------
在你的 项目.cpp文件中加入如下代码

//====利用互斥,防止多个程序运行====
HANDLE hMutex=CreateMutex(NULL,TRUE,"WeightManager"); //进程中的名称
if(hMutex==NULL||GetLastError() == ERROR_ALREADY_EXISTS)
{
ShowMessage("稽核票管理软件已经运行.");
CloseHandle(hMutex);
return false;
}