public void setVersionNumber(int majorVersion, int minorVersion, int bugfixVersion) {
   int mostSignificantVersion = majorVersion << 16 | minorVersion;
   int leastSignificantVersion = bugfixVersion << 16;
   myVersionInfo
       .getFixedFileInfo()
       .setFileVersion(mostSignificantVersion, leastSignificantVersion);
   myVersionInfo
       .getFixedFileInfo()
       .setProductVersion(mostSignificantVersion, leastSignificantVersion);
 }
  private void verifyVersionInfo() throws IOException {
    String versionInfoPath = myExePath + ".version";
    RandomAccessFile versionInfoStream = new RandomAccessFile(versionInfoPath, "rw");
    try {
      myVersionInfo.resetOffsets(0);
      myVersionInfo.write(versionInfoStream);
    } finally {
      versionInfoStream.close();
    }

    VersionInfo copy = new VersionInfo();
    copy.read(
        new OffsetTrackingInputStream(new DataInputStream(new FileInputStream(versionInfoPath))));
  }
  public void load() throws IOException {
    RandomAccessFile stream = new RandomAccessFile(myTemplate, "r");
    ExeReader formatReader = new ExeReader(myTemplate.getName(), ExeFormat.UNKNOWN);
    formatReader.read(stream);
    stream.seek(0L);
    myReader = new ExeReader(myTemplate.getName(), formatReader.getExeFormat());
    myReader.read(stream);
    stream.close();
    SectionReader sectionReader = myReader.getSectionReader(".rsrc");
    ResourceSectionReader resourceReader = (ResourceSectionReader) sectionReader.getMember(".rsrc");
    myRoot = resourceReader.getRoot();
    DirectoryEntry subDir = myRoot.findSubDir("IRD6");
    myStringTableDirectory = new StringTableDirectory(subDir);

    RawResource versionInfoResource = getVersionInfoResource();
    ByteArrayInputStream bytesStream =
        new ByteArrayInputStream(versionInfoResource.getBytes().getBytes());

    myVersionInfo = new VersionInfo();
    myVersionInfo.read(new OffsetTrackingInputStream(new DataInputStream(bytesStream)));
  }
 private void saveVersionInfo() throws IOException {
   ByteArrayOutputStream baos = new ByteArrayOutputStream();
   myVersionInfo.resetOffsets(0);
   myVersionInfo.write(new DataOutputStream(baos));
   getVersionInfoResource().setBytes(baos.toByteArray());
 }
 public void setVersionInfoString(String key, String value) {
   StringTable stringTable = myVersionInfo.getStringFileInfo().getFirstStringTable();
   if (stringTable != null) {
     stringTable.setStringValue(key, value);
   }
 }