使用Maven项目,在pom.xml文件中注入:
<dependency><groupId>com.kichik.pecoff4j</groupId><artifactId>pecoff4j</artifactId><version>0.4.1</version></dependency>
程序代码:
import com.kichik.pecoff4j.PE;
import com.kichik.pecoff4j.ResourceDirectory;
import com.kichik.pecoff4j.ResourceEntry;
import com.kichik.pecoff4j.constant.ResourceType;
import com.kichik.pecoff4j.io.DataReader;
import com.kichik.pecoff4j.io.PEParser;
import com.kichik.pecoff4j.resources.StringFileInfo;
import com.kichik.pecoff4j.resources.StringPair;
import com.kichik.pecoff4j.resources.StringTable;
import com.kichik.pecoff4j.resources.VersionInfo;
import com.kichik.pecoff4j.util.ResourceHelper;/*** @version 1.0* @description 测试* @className Test*/
public class Test {public static void main(String[] args) {try {String filePath = "E:\\开发工具\\Docker Desktop Installer.exe";PE pe = PEParser.parse(filePath);ResourceDirectory rd = pe.getImageData().getResourceTable();ResourceEntry[] entries = ResourceHelper.findResources(rd, ResourceType.VERSION_INFO);for (ResourceEntry entry : entries) {byte[] data = entry.getData();VersionInfo version = VersionInfo.read(new DataReader(data));StringFileInfo strings = version.getStringFileInfo();StringTable table = strings.getTables().get(0);for (StringPair pair : table.getStrings()) {System.out.println(pair.getKey() + " = " + pair.getValue());}}} catch (Exception e) {e.printStackTrace();}}
}
输出示例:
CompanyName = Docker Inc.
FileDescription = Docker Desktop Installer
FileVersion = 4.29.0.145265
LegalCopyright = Copyright © 2015-2024 Docker Inc.
OriginalFilename = Docker Desktop Installer.exe
ProductName = Docker Desktop Installer
ProductVersion = 4.29.0.145265
InternalName = Docker Desktop Installer.exe
Assembly Version = 4.29.0
原exe文件详细信息: