1
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
El mío está funcionando bien
#include <windows.h>
#include <tlhelp32.h>
#include <tchar.h>
int gMaxGameInstances = 20;
bool IsProcessRunning(const char *ProcessName, int maxProcess)
{
PROCESSENTRY32 pe32 = {sizeof(PROCESSENTRY32)};
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
int Temp = 0;
if (Process32First(hSnapshot, &pe32))
{
do
{
if (_tcsicmp(pe32.szExeFile, ProcessName) == 0)
{
Temp++;
//gLog.Output(LOG_DEBUG, "CheckMaxGameInstances: %d: %d", Temp, maxProcess);
if (Temp > maxProcess)
{
CloseHandle(hSnapshot);
return true;
}
}
} while (Process32Next(hSnapshot, &pe32));
}
CloseHandle(hSnapshot);
return false;
}
void CheckMaxGameInstances() // OK
{
if (gMaxGameInstances == 0)
{
return;
}
if (IsProcessRunning("main.exe", gMaxGameInstances))
{
//gLog.Output(LOG_DEBUG, "CheckMaxGameInstances: SafeExitProcess");
ExitProcess(1);
}
}
Copy to main
Si estas aplicando el código de arriba, dice que el Maximo es 20, no 2 como pones en tu video. No me puse a ver cuantas ventas abriste, pero el titulo de tu video dice 2.
#include <windows.h>
#include <tlhelp32.h>
#include <tchar.h>
int gMaxGameInstances = 20;
bool IsProcessRunning(const char *ProcessName, int maxProcess)
{
PROCESSENTRY32 pe32 = {sizeof(PROCESSENTRY32)};
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
int Temp = 0;
if (Process32First(hSnapshot, &pe32))
{
do
{
if (_tcsicmp(pe32.szExeFile, ProcessName) == 0)
{
Temp++;
//gLog.Output(LOG_DEBUG, "CheckMaxGameInstances: %d: %d", Temp, maxProcess);
if (Temp > maxProcess)
{
CloseHandle(hSnapshot);
return true;
}
}
} while (Process32Next(hSnapshot, &pe32));
}
CloseHandle(hSnapshot);
return false;
}
void CheckMaxGameInstances() // OK
{
if (gMaxGameInstances == 0)
{
return;
}
if (IsProcessRunning("main.exe", gMaxGameInstances))
{
//gLog.Output(LOG_DEBUG, "CheckMaxGameInstances: SafeExitProcess");
ExitProcess(1);
}
}
Copy to main
it works very well :)What library did you add it to?
