init commit
This commit is contained in:
30
Debug_64ch_Decoder_Optimize/PubLibrary/InifileHelper.py
Normal file
30
Debug_64ch_Decoder_Optimize/PubLibrary/InifileHelper.py
Normal file
@@ -0,0 +1,30 @@
|
||||
# -*-coding:utf-8 -*-
|
||||
import configparser
|
||||
import os
|
||||
import sys
|
||||
from audioop import error
|
||||
|
||||
BASE_DIR = os.getcwd()
|
||||
IniFileName = os.path.join(BASE_DIR, 'config.ini')
|
||||
# IniFileName=os.path.join( 'config.ini')
|
||||
|
||||
def IniWrite(section,keyname,value):
|
||||
# 创建ConfigParser对象
|
||||
config = configparser.ConfigParser()
|
||||
config.read(IniFileName,encoding='utf-8')
|
||||
with open(IniFileName, 'w') as configfile:
|
||||
if not config.has_section(section):
|
||||
config.add_section(section)
|
||||
config[section][keyname]=str(value)
|
||||
config.write(configfile)
|
||||
|
||||
def IniRead(section,key):
|
||||
|
||||
try:
|
||||
config = configparser.ConfigParser()
|
||||
config.read(IniFileName,encoding='utf-8')
|
||||
return config[section][key]
|
||||
except error as e:
|
||||
print(e)
|
||||
# 读取特定section和键的值
|
||||
return '5'
|
||||
15
Debug_64ch_Decoder_Optimize/PubLibrary/RunOnce.py
Normal file
15
Debug_64ch_Decoder_Optimize/PubLibrary/RunOnce.py
Normal file
@@ -0,0 +1,15 @@
|
||||
import ctypes
|
||||
import sys
|
||||
|
||||
|
||||
def is_program_running(name='Global\\Decoder'):
|
||||
# 创建互斥体
|
||||
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
|
||||
Reference in New Issue
Block a user