Heaventools

   English English  Deutsch Deutsch  Русский Русский

startseite   produkte   resource tuner console   beispiel-skripts

Icons hinzufügen oder ersetzen

Dieser Skript zeigt, wie man die Icons zu Testanwendungen hinzufügt oder mit neuen Icons ersetzt.

The script adds or replaces icons in the test EXE file with icons from .ico files in the "..\Demo\Src" folder. After that, it outputs the resulting resource tree to a log file and/or the console screen. The modified file is saved to the Destination folder.

Note: when copying out the script code, please make sure there's no line breaks. This is a requirement of VBScript: the entire command must be on one line.

'------------------------------------------------------------------------------
'
' This code shows how to modify icons in executables.
'
' The script will add or replace icons in demoapp1.exe with icons from .ico
' files in the "Demo\Src" folder. 
'
' The resulting files will be created in the directory named "..\Demo\Release"
' Check the log file to see the Resource Tree built. 
'
'------------------------------------------------------------------------------

Sub Main
  PEFileProxy.PostDebugString "Updating the checksum in the PE file header is enabled." 
  PEFileProxy.UpdateCheckSum = True 

  PEFileProxy.PostDebugString "The creation of a backup copy is disabled." 
  PEFileProxy.CreateBackUp = False 

  PEFileProxy.PostDebugString "Opening a file..."
  PEFileProxy.OpenFile ".\demo\src\demoapp1.exe"
  if (PEFileProxy.Terminated) then
    PEFileProxy.PostDebugString "Opening a file produced a fatal error."
  else
    PEFileProxy.PostDebugString "File successfully opened."
    if (not PEFileProxy.HasResources) then
      PEFileProxy.PostDebugString "The file contains no resources."
    else
      PEFileProxy.PostDebugString "The file contains resources."

      LangID = 0 ' Default

      PEFileProxy.PostDebugString "Changing/adding the main application icon..."
      ResourcesProxy.ChangeIcon "", LangID, CREATE_IF_NOT_EXIST, REPLACE_IF_ITEM_EXISTS,
 ".\demo\src\icon_1_32x32_4bit.ico"
      ResourcesProxy.ChangeIcon "", LangID, GET_DEFAULT_IF_NOT_EXIST, REPLACE_IF_ITEM_EXISTS,
 ".\demo\src\icon_2_16x16_4bit.ico"

      PEFileProxy.PostDebugString "Adding two more icons..."
      ResourcesProxy.ChangeIcon "1", LangID, CREATE_IF_NOT_EXIST, REPLACE_IF_ITEM_EXISTS,
 ".\demo\src\icon_3_32x32_8bit.ico"
      ResourcesProxy.ChangeIcon "1", LangID, CREATE_IF_NOT_EXIST, REPLACE_IF_ITEM_EXISTS,
 ".\demo\src\icon_4_16x16_32bit.ico"

      PEFileProxy.PostDebugString "Compiling all changes..."
      PEFileProxy.Compile

      PEFileProxy.PostDebugString ""
      PEFileProxy.PostDebugString "Resource Tree built by RTC:"
      ResourcesProxy.ResourceTreeToLog
      PEFileProxy.PostDebugString ""

      PEFileProxy.PostDebugString "Saving changes to a new file..."
      PEFileProxy.SaveAsNewImage ".\demo\release\demoapp1.exe"
    end if
    PEFileProxy.PostDebugString "Closing this file..."
    PEFileProxy.CloseFile
  end if
end Sub
'------------------------------------------------------------------------------

Once you run the script, RTC outputs the Resource Tree to a log file, so you can see the changes made:

Resource Tree built by RTC:
----------------------------------------
 [Cursor (1)]
     1: 32x32 1b, Neutral (0)
     2: 32x32 1b, Neutral (0)
     3: 32x32 1b, Neutral (0)
     4: 32x32 1b, Neutral (0)
     5: 32x32 1b, Neutral (0)
     6: 32x32 1b, Neutral (0)
     7: 32x32 1b, Neutral (0)
 [Bitmap (2)]
     BBABORT: Neutral (0)
     BBALL: Neutral (0)
     BBCANCEL: Neutral (0)
     BBCLOSE: Neutral (0)
     BBHELP: Neutral (0)
     BBIGNORE: Neutral (0)
     BBNO: Neutral (0)
     BBOK: Neutral (0)
     BBRETRY: Neutral (0)
     BBYES: Neutral (0)
     CDROM: Neutral (0)
     CLOSEDFOLDER: Neutral (0)
     CURRENTFOLDER: Neutral (0)
     EXECUTABLE: Neutral (0)
     FLOPPY: Neutral (0)
     HARD: Neutral (0)
     KNOWNFILE: Neutral (0)
     NETWORK: Neutral (0)
     OPENFOLDER: Neutral (0)
     RAM: Neutral (0)
     UNKNOWNFILE: Neutral (0)
     XCLR_BMP: German - Switzerland (2055)
 [Icon (3)]
     * 1: 32x32 4b, Russian (1049)
     2: 32x32 8b, Russian (1049)
     + 3: 16x16 4b, Neutral (0)
     + 4: 32x32 8b, Neutral (0)
     + 5: 32x32 4b, Neutral (0)
 [String (6)]
     4080: Neutral (0)
     4081: Neutral (0)
     4082: Neutral (0)
     4083: Neutral (0)
     4084: Neutral (0)
     4085: Neutral (0)
     4086: Neutral (0)
     4087: Neutral (0)
     4088: Neutral (0)
     4089: Neutral (0)
     4090: Neutral (0)
     4091: Neutral (0)
     4092: Neutral (0)
     4093: Neutral (0)
     4094: Neutral (0)
     4095: Neutral (0)
     4096: Neutral (0)
 [RC Data (10)]
     DVCLAL: Neutral (0)
     PACKAGEINFO: Neutral (0)
     TFORM1: Neutral (0)
 [Cursor Group (12)]
     32761: Neutral (0)
     32762: Neutral (0)
     32763: Neutral (0)
     32764: Neutral (0)
     32765: Neutral (0)
     32766: Neutral (0)
     32767: Neutral (0)
 [Icon Group (14)]
     * MAINICON: Russian (1049)
     XCLR_ICON: German - Switzerland (2055)
     + 1: Neutral (0)
 [Version (16)]
     1: English (US) (1033)
----------------------------------------
Legend: [Name (Ord)] - Type; "+" - New; "-" - Deleted; "*" - Modified

Um die Änderungen, die man in Test-EXE-Dateien gemacht hat, zu sehen, empfehlen wir die Benutzung von Resource Tuner GUI, einem visuellen Ressourcen-Editor.

Nachdem Sie Resource Tuner Console installiert haben, finden Sie die Beispiel-Skripts in dem Verzeichnis, in dem RTC installiert wurde. Das Setup-Programm erstellt auch das Verzeichnis "..\Demo" im RTC-Verzeichnis, der Testanwendungen im Unterverzeichnis "..\Demo\Src" enthält.

 

So verwenden Sie die Skripts: The Complete Illustrated Step by Step Guide To Using Scripts

Download 60-Tage Resource Tuner Console Testversion     Kaufen Sie die Vollversion