判断当前进程是否已经打开C++
2021-01-14 18:15
标签:snap nap mes roc char and har end first 判断当前进程是否已经打开C++ 标签:snap nap mes roc char and har end first 原文地址:https://www.cnblogs.com/foreversdf/p/12900519.htmlint foundProcessByName(const char *filename)
{
int foundProcessTimes = 0;
HANDLE hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPALL, NULL);
PROCESSENTRY32 pEntry;
pEntry.dwSize = sizeof(pEntry);
BOOL hRes = Process32First(hSnapShot, &pEntry);
while (hRes)
{
_bstr_t b(pEntry.szExeFile);
const char* c = b;
if (strcmp(c, filename) == 0)
{
std::wstring ws(pEntry.szExeFile);
std::string test(ws.begin(), ws.end());
//qDebug() 1)
{
//进程已打开。
}