1.添加防复制运行机制;2.调整提示框;3.完完善打包
parent
adeb824f62
commit
1c3cced613
|
@ -0,0 +1,4 @@
|
|||
开发过程记录:
|
||||
cx_Freeze:编译代码为独立运行的exe文件(bdist_msi定制性太差)
|
||||
inno setup:打包程序。主要功能:语言选择、安装位置、生成快速启动栏和桌面图标、卸载程序
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
; 脚本由 Inno Setup 脚本向导 生成!
|
||||
; 有关创建 Inno Setup 脚本文件的详细资料请查阅帮助文档!
|
||||
|
||||
#define MyAppName "Gutin谷田会议视频录播管理系统"
|
||||
#define MyAppVersion "0.3"
|
||||
#define MyAppPublisher "珠海市谷田音频科技有限公司"
|
||||
#define MyAppExeName "RecordWindow.exe"
|
||||
|
||||
[Setup]
|
||||
; 注: AppId的值为单独标识该应用程序。
|
||||
; 不要为其他安装程序使用相同的AppId值。
|
||||
; (生成新的GUID,点击 工具|在IDE中生成GUID。)
|
||||
AppId={{B91CC43B-FF1E-4169-B77C-1B259E89F014}
|
||||
AppName={#MyAppName}
|
||||
AppVersion={#MyAppVersion}
|
||||
;AppVerName={#MyAppName} {#MyAppVersion}
|
||||
AppPublisher={#MyAppPublisher}
|
||||
;AppPublisherURL={#MyAppURL}
|
||||
;AppSupportURL={#MyAppURL}
|
||||
;AppUpdatesURL={#MyAppURL}
|
||||
DefaultDirName=d:\gutin-record
|
||||
DefaultGroupName=Gutin谷田会议视频录播管理系统
|
||||
AllowNoIcons=yes
|
||||
OutputDir=D:\dev\record\out-test
|
||||
OutputBaseFilename=Gutin谷田会议视频录播管理系统-{#MyAppVersion}
|
||||
SetupIconFile=C:\Users\lv\ctest\record-camera-and-screen\resource\gutin.ico
|
||||
Compression=lzma
|
||||
SolidCompression=yes
|
||||
|
||||
[Tasks]
|
||||
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0
|
||||
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
|
||||
Name: "startupicon"; Description: "开机启动"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
|
||||
|
||||
[Files]
|
||||
Source: "D:\dev\record\record-win\RecordWindow.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\dev\record\record-win\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
|
||||
; 注意: 不要在任何共享系统文件上使用“Flags: ignoreversion”
|
||||
|
||||
[Icons]
|
||||
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
|
||||
;Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}"
|
||||
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
|
||||
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
|
||||
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon
|
||||
|
||||
[Run]
|
||||
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
|
||||
|
||||
|
||||
[Registry]
|
||||
Root: HKCU; Subkey: "SOFTWARE\Gutin\Record"; ValueType:string; ValueName: "InstallDir{#GetDateTimeString('dd/mm/yyyy hh:nn:ss', '-', ':')}"; ValueData: "{app}"; Flags: uninsdeletevalue createvalueifdoesntexist;
|
||||
;遇到的问题HKLM节点无法写入
|
||||
;Root: HKCU; Subkey: "Software\My Company Test"; Flags: uninsdeletekeyifempty
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
# 获取Windows的已打的补丁号
|
||||
import winreg
|
||||
from winreg import *
|
||||
import re
|
||||
import os
|
||||
import datetime
|
||||
import hashlib
|
||||
|
||||
def subRegKey(key, pattern, patchlist):
|
||||
# 个数
|
||||
count = QueryInfoKey(key)
|
||||
for index in range(len(QueryInfoKey(key))):
|
||||
# 获取标题
|
||||
name = EnumKey(key, index)
|
||||
|
||||
result = patch.match(name)
|
||||
if result:
|
||||
patchlist.append(result.group(1))
|
||||
sub = OpenKey(key, name)
|
||||
subRegKey(sub, pattern, patchlist)
|
||||
CloseKey(sub)
|
||||
|
||||
|
||||
def check_run_state():
|
||||
#验证运行有效性逻辑:
|
||||
#一、判断是否正常安装
|
||||
#判断条件:软件安装时在注册表“HKEY_CURRENT_USER\\SOFTWARE\\Gutin\\Record“记录下安装目录
|
||||
#二、非正常安装有效时间为三个月,且只能发生一次
|
||||
|
||||
#验证当前运行目录是否存在注册表中
|
||||
qualified = False
|
||||
run_dir = os.path.abspath('.')
|
||||
# print('run_dir:%s' % run_dir)
|
||||
reg_path = 'SOFTWARE\\Gutin\\Record'
|
||||
feature_name ='InstallDir'
|
||||
key = OpenKey(HKEY_CURRENT_USER, reg_path, access = KEY_READ)
|
||||
items = QueryInfoKey(key)
|
||||
for i in range(items[1]):
|
||||
item = EnumValue(key, i)
|
||||
name = item[0]
|
||||
value = item[1]
|
||||
type = item[2]
|
||||
if name and name.find(feature_name)>=0:
|
||||
if os.path.samefile(value, run_dir):
|
||||
qualified = True
|
||||
break;
|
||||
|
||||
if not qualified:
|
||||
#查找非正常安装目录记录
|
||||
#记录以运行目录的hash值作为键名,值为首次运行的时间
|
||||
time_format= '%Y-%m-%d %H:%M:%S'
|
||||
run_time = None
|
||||
# run_dir_hash = hashlib.md5(run_dir.encode('utf-8')).hexdigest()
|
||||
unqualified_key_name = 'Unqualified'
|
||||
has_unqualified = False
|
||||
for i in range(items[1]):
|
||||
item = EnumValue(key, i)
|
||||
name = item[0]
|
||||
value = item[1]
|
||||
type = item[2]
|
||||
if name == unqualified_key_name:
|
||||
has_unqualified = True
|
||||
run_time = value
|
||||
|
||||
if not has_unqualified:
|
||||
#如果不存在,创建
|
||||
run_time = datetime.datetime.now().strftime(time_format)
|
||||
key = OpenKey(HKEY_CURRENT_USER, reg_path, access = KEY_SET_VALUE)
|
||||
SetValueEx(key, unqualified_key_name, 0, REG_SZ, run_time)
|
||||
|
||||
#判断时限
|
||||
# now = datetime.datetime.strptime('2018-06-22 12:11:51', time_format)
|
||||
now = datetime.datetime.now()
|
||||
run_time_obj = datetime.datetime.strptime(run_time, time_format)
|
||||
print('first run_time:%s' % run_time)
|
||||
print('now:%s' % now.strftime(time_format))
|
||||
|
||||
# qual_days = 1 - (now - run_time_obj).days
|
||||
# print('qualified days:%d' % (qual_days))
|
||||
print('qualified hours:%d' % (((now - run_time_obj).total_seconds())//3600))
|
||||
qual_hours = 18 - ((now - run_time_obj).total_seconds())//3600
|
||||
# if qual_days > 0:
|
||||
if qual_hours > 0:
|
||||
qualified = True
|
||||
|
||||
CloseKey(key)
|
||||
return qualified
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# patchlist = []
|
||||
# updates = 'SOFTWARE\\Gutin\\Record'
|
||||
# patch = re.compile('InstallDir.+')
|
||||
# key = OpenKey(HKEY_CURRENT_USER, updates, access = KEY_READ)
|
||||
# items = QueryInfoKey(key)
|
||||
# print(items[1])
|
||||
# for i in range(items[1]):
|
||||
# item = EnumValue(key, i)
|
||||
# name = item[0]
|
||||
# value = item[1]
|
||||
# type = item[2]
|
||||
# if name and name.find('InstallDir')>=0:
|
||||
# print(item)
|
||||
|
||||
print(check_run_state())
|
||||
|
||||
# print(items)
|
||||
# CloseKey(key)
|
Loading…
Reference in New Issue