zoukankan      html  css  js  c++  java
  • 判断exe程序是否在运行

    public static boolean isRunning(String processName) {
      BufferedReader bufferedReader = null;
      try {
        Process proc = Runtime.getRuntime().exec("tasklist /FI "IMAGENAME eq " + processName + """);
        bufferedReader = new BufferedReader(new InputStreamReader(
        proc.getInputStream()));
        String line = null;
        while ((line = bufferedReader.readLine()) != null) {
          if (line.contains(processName)) {// 判断是否存在
            return true;
          }
        }
        return false;
      } catch (Exception ex) {
        ex.printStackTrace();
        return false;
      } finally {
        if (bufferedReader != null) {
          try {
            bufferedReader.close();
          } catch (Exception ex) {
          }
        }
      }
    }

  • 相关阅读:
    P5304旅行者(比bk201还要流氓的解法)
    考试T1护花
    考试T2修剪草坪
    考试T3麻将
    账号密码
    T7
    P2885 [USACO07NOV]电话线Telephone Wire
    P4965 薇尔莉特的打字机
    P1505 [国家集训队]旅游
    T2
  • 原文地址:https://www.cnblogs.com/bd195746/p/7676110.html
Copyright © 2011-2022 走看看