1 Star 0 Fork 0

tinode/python-windows-tiler

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
singleinstance.py 678 Bytes
一键复制 编辑 原始数据 按行查看 历史
Tzbob 提交于 2012-04-15 13:46 . initial commit
#SOURCE: http://code.activestate.com/recipes/474070-creating-a-single-instance-application/
from win32event import CreateMutex
from win32api import CloseHandle, GetLastError
from winerror import ERROR_ALREADY_EXISTS
class Singleinstance:
""" Limits application to single instance """
def __init__(self):
self.mutexname = "testmutex_{D0E858DF-985E-4907-B7FB-8D732C3FC3B9}"
self.mutex = CreateMutex(None, False, self.mutexname)
self.lasterror = GetLastError()
def alreadyrunning(self):
return (self.lasterror == ERROR_ALREADY_EXISTS)
def __del__(self):
if self.mutex:
CloseHandle(self.mutex)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/jscloud/python-windows-tiler.git
git@gitee.com:jscloud/python-windows-tiler.git
jscloud
python-windows-tiler
python-windows-tiler
master

搜索帮助