zoukankan      html  css  js  c++  java
  • QT_强杀进程

    #ifdef WIN32
        bool res = false;
        HANDLE    hToolHelp32Snapshot;
        hToolHelp32Snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
        PROCESSENTRY32    pe = { sizeof(PROCESSENTRY32) };
        BOOL  isSuccess = Process32First(hToolHelp32Snapshot, &pe);
        while (isSuccess)
        {
            size_t len = WideCharToMultiByte(CP_ACP, 0, pe.szExeFile, wcslen(pe.szExeFile), NULL, 0, NULL, NULL);
            char *des = (char *)malloc(sizeof(char) * (len + 1));
            WideCharToMultiByte(CP_ACP, 0, pe.szExeFile, wcslen(pe.szExeFile), des, len, NULL, NULL);
            des[len] = '';
            if (!strcmp(des, appName.toStdString().c_str()))
            {
                appPath = getProcessPathForWin(pe.th32ProcessID);
                TerminateProcess(OpenProcess(PROCESS_TERMINATE, FALSE, pe.th32ProcessID), 0);
                res = true;
            }
            free(des);
            isSuccess = Process32Next(hToolHelp32Snapshot, &pe);
        }
        CloseHandle(hToolHelp32Snapshot);
        return res;
    #else
        QString killProcess = "killall appName";
    int ret = system(QStringConvertChar(killProcess));
    qDebug()
    << QString::fromStdString(getTime(1)) << "killProcess result:" << ret << "----" << killProcess; return ret == 0 ? true : false;

    #endif
  • 相关阅读:
    MSSQL Join的使用
    MSSQL2008 常用sql语句
    Process使用
    c# 多线程 调用带参数函数
    C# 多线程参数传递
    C# 单例模式代码
    C#调用存储过程
    页面布局
    构建:vue项目配置后端接口服务信息
    浏览器工作原理(二):浏览器渲染过程概述
  • 原文地址:https://www.cnblogs.com/amwuau/p/9776708.html
Copyright © 2011-2022 走看看