C++通过vmware.exe检测虚拟机

bool    isVmareMachine()
{
HANDLE  hProcessSnap = ::CreateToolhelp32Snapshot(
        TH32CS_SNAPPROCESS,  //创建所有进程的快照
        0                    //0表示当前进程
        );
    PROCESSENTRY32  entry = { 0 };
    entry.dwSize = sizeof(entry);
    bool    bFind = Process32First(hProcessSnap, &entry);
    if (!bFind){
        return false;
    }
    while (bFind)
    {

        CString s;
        s.Format(TEXT("%s"), entry.szExeFile);

        if (s == "vmware.exe")
        {
            return true;
        }

        bFind = Process32Next(hProcessSnap, &entry);
    }
}

你可能感兴趣的:(c++)