- 使用pyi-grab_version.exe 生成 标準Windows電腦軟體(例如WeChat.exe)的版本資訊檔案 file_version_info.txt
F:\python_code>c:\Python27\Scripts\pyi-grab_version.exe "C:\Program Files (x86)\Tencent\WeChat\WeChat.exe"
Version info written to: file_version_info.txt
2.file_version_info.txt内容說明
(其中注意因為這個版本資訊是嚴格的資料結構,是以最好不要随意修改,有可能導緻版本資訊檔案失效,推薦使用是notepad++更改。)
# UTF-8
#
# For more details about fixed file info 'ffi' see:
# http://msdn.microsoft.com/en-us/library/ms646997.aspx
VSVersionInfo(
ffi=FixedFileInfo(
# filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4)
# Set not needed items to zero 0. filevers和prodvers應該始終是包含四個項的元組:(1、2、3、4),将不需要的項設定為0
filevers=(3, 6, 0, 0), # 檔案版本******,滑鼠懸浮exe會顯示,也顯示在 詳細資訊-檔案版本,這個是檢測版本的依據
prodvers=(3, 6, 0, 0), # 生産商,未見顯示在哪裡
# Contains a bitmask that specifies the valid bits 'flags'r
mask=0x3f, # 兩個位掩碼
# Contains a bitmask that specifies the Boolean attributes of the file.
flags=0x0,
# The operating system for which this file was designed.
# 0x4 - NT and there is no need to change it.
OS=0x40004, # 為其設計此檔案的作業系統,0x4-NT,無需更改它
# The general type of file.
# 0x1 - the file is an application.
fileType=0x1, # 檔案的正常類型,0x1-該檔案是一個應用程式
# The function of the file.
# 0x0 - the function is not defined for this fileType
subtype=0x0, # 檔案的功能,0x0表示該檔案類型未定義
# Creation date and time stamp.
date=(0, 0) # 建立日期和時間戳
),
kids=[
StringFileInfo(
[
StringTable(
u'080404b0',
[StringStruct(u'CompanyName', u'Tencent'), # 公司,滑鼠懸浮exe會顯示
StringStruct(u'FileDescription', u'WeChat'), # 檔案說明,滑鼠懸浮exe會顯示,也會顯示在 詳細資訊-檔案說明
StringStruct(u'FileVersion', u'3.6.0.0'), # 沒見哪裡顯示
StringStruct(u'LegalCopyright', u'Copyright (C) 2021 Tencent'), # 版權,會顯示在 詳細資訊-版權
StringStruct(u'ProductName', u'WeChat'), # 原始檔案名,會顯示在 詳細資訊-原始檔案名
StringStruct(u'ProductVersion', u'3.6.0.0')]) # 産品版本,會顯示在 詳細資訊-産品版本
]),
VarFileInfo([VarStruct(u'Translation', [2052, 1200])]) # 語言,中文簡體
]
)
- 打包.py生成exe檔案(直接稍加修改file_version_info.txt,儲存資訊)
c:\Python27\Scripts\pyinstaller.exe --version-file file_version_info.txt -F test.py
- 選取一個喜歡.ico檔案,作為自己軟體的圖示,打包進exe中
c:\Python27\Scripts\pyinstaller.exe -i setup.ico --version-file file_version_info.txt -F test.py
- 生成的exe檔案