代码如下:

 # -*- coding: UTF8 -*-
from win32com.client import Dispatch
import win32com
import sys, os
from PyQt4 import QtCore, QtGui class Logicpy(QtGui.QWidget):
def __init__(self):
super(Logicpy, self).__init__()
self.resize(100, 100)
mythis = os.path.basename(os.path.realpath(sys.argv[0])) # 获得当前文件的名字
exist = self.proc_exist(mythis)
if exist:
Ok = QtGui.QMessageBox.question(self, (u'提示'),(u'已经运行'), QtGui.QMessageBox.Yes)
if Ok == QtGui.QMessageBox.Yes:
exit()
# QtCore.QCoreApplication.quit()
# QtGui.qApp.quit # 退出 #判断该进程是否存在
def proc_exist(self, process_name):
is_exist = False
wmi = win32com.client.GetObject('winmgmts:')
processCodeCov = wmi.ExecQuery('select * from Win32_Process where name=\"%s\"' %(process_name))
if len(processCodeCov) > 2:
is_exist = True
return is_exist if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
Logic = Logicpy()
Logic.show()
sys.exit(app.exec_())

效果:

Python 打包程序判断是否已经运行的更多相关文章

  1. 【python】python打包生成的exe文件运行时提示缺少模块

    事情是这样的我用打包命令:pyinstaller -F E:\python\clpicdownload\mypython.py打包了一个exe程序,但是运行时提示我缺 少bs4模块然后我就去查pyin ...

  2. Python打包程序

    到py2exe的官网下载程序,注意对应的python版本,比如所用的python版本为2.7,那么就下载适配2.7版本的py2exe软件 下载完成后安装(与普通软件安装方式相同) 2 将要转换的pyt ...

  3. PYTHON的程序在LINUX后台运行

    1.nohup 命令 nohup nohup 命令 用途:LINUX命令用法,不挂断地运行命令. 语法:nohup Command [ Arg ... ] [ & ] 描述:nohup 命令运 ...

  4. Python 打包程序

    一.打包成exe 1.安装pyinstaller #只要你能FQ连接https://pypi.python.org/pypi下载会很快,不用担心超时问题. https://pypi.python.or ...

  5. 【Python打包成exe方法】——已解决导入第三方包无法打包的问题

    ​ 前言 在我们写代码的过程中,我们开发的脚本一般都会用到一些第三方包,可能别人也需要用到我们的脚本,如果我们将我们的xx.py文件发给他,他是不能直接用的,他还需要安装python解释器,甚至还要安 ...

  6. python 脚本中使用了第三方openpyxl 打包程序运行提示ImportError:cannot import name __version__

    最近写了一个脚本,脚本中使用了第三方openpyxl(openpyxl是使用 pip install openpyxl 下载的),先是使用py2exe打包程序,打包过程中提示很多文件没有包含,在没有仔 ...

  7. Python进阶-打包程序为exe

    操作系统:win7 x64 运行环境:Python3.5 安装PyInstaller 第一步:下载PyInstaller https://github.com/pyinstaller/pyinstal ...

  8. Python打包成exe程序

    如何把.py文件打包成.exe可执行程序. 这里选择用PyInstaller 3.0来打包,PyInstaller 3.0下载地址:https://pypi.python.org/pypi/PyIns ...

  9. python pyinstaller 打包程序报错解决

    python打包exe,各种入坑 一.安装PyInstaller 1.安装pywin32 pip命令安装:pip install pywin32(推荐) 2.安装Pyinstaller pip命令安装 ...

随机推荐

  1. Unity3D Pro破解

    Win破解方法: 全新安装Unity且未打开Unity后!!! 下载程序, 右键管理员运行, 点击Browse选择Unity安装目录内的Editor文件夹, 确定. 然后点击大按钮PATCH即可, 如 ...

  2. 2015校招网易C/C++工程师笔试题(附答案)

    1. #include < filename.h >和#i nclude “filename.h” 有什么区别?   答:对于#i nclude < filename.h >, ...

  3. Python自动化装饰器问题解疑

    问题一 到底是怎么执行的? import time def timer(timeout=0): def decorator(func): def wrapper(*args, **kwargs): # ...

  4. 使用jar命令打war包

    1.打开cmd进入web项目发布文件夹 2.,输入jar -cvf qxpt.war * (*表示当前目录下所有子目录) 3,回车等待执行完成就可以了 4.如果web项目发布文件夹有多个文件夹,而打w ...

  5. TortoiseGit 添加邮箱 失败保存配置

    解决方法   将保存至改为此版本库

  6. n全排列输出和 n个数的组合(数字范围a~b)

    n全排列输出: int WPermutation(int num, bool bRepeat) num表示num全排列 bRepeat标志是否产生重复元素的序列. int Permutation(in ...

  7. 【leetcode】Restore IP Addresses

    Restore IP Addresses Given a string containing only digits, restore it by returning all possible val ...

  8. servlet 和filter 的生命周期说明

    servlet : 当客户端第一次访问servlet的时候,服务器就会创建servlet实例,servlet 就会执行init方法,每次请求,服务器会开一个新的线程访问servlet中得service ...

  9. Unity3d UGUI序列帧动画

    代码 using UnityEngine; using System.Collections; using System.Collections.Generic; using UnityEngine. ...

  10. ios 在storyboard 和 xib中,显示自定义view的预览效果

    发现FSCalendar这个控件能在xib中显示预览效果,是怎么实现的呢?其中涉及的知识又有哪些? 主要就是IBInspectable 和 IB_DESIGNABLE 先看 IBInspectable ...