17 lines
394 B
Python
17 lines
394 B
Python
|
|
import ctypes
|
||
|
|
import sys
|
||
|
|
|
||
|
|
|
||
|
|
def is_program_running(name='Global\\Parser_main'):
|
||
|
|
# 创建互斥体
|
||
|
|
mutex_name =name
|
||
|
|
h_mutex = ctypes.windll.kernel32.CreateMutexW(None, False, mutex_name)
|
||
|
|
|
||
|
|
# 检查互斥体是否已经存在
|
||
|
|
if ctypes.windll.kernel32.GetLastError() == 183: # ERROR_ALREADY_EXISTS
|
||
|
|
print("程序已经在运行.")
|
||
|
|
return True
|
||
|
|
|
||
|
|
return False
|
||
|
|
|