Heaventools

   English English  Deutsch Deutsch

startseite   produkte   resource tuner console   beispiel-skripts

Ein XML-Manifest für die User Access Control hinzufügen oder ersetzen

Dieser Script zeigt, wie man eine Anwendung-Manifest-Datei hinzufügt oder ersetzt und die Änderungen im Ressourcen-Baumverzeichnis in eine Logdatei ausgibt.

Hinweis: Wenn Sie den Script-Code kopieren, stellen Sie bitte sicher, dass er keine Zeilenumbrüche enthält. Dies ist eine Anforderung von VBScript: der gesamte Befehl muss in einer Zeile stehen.

'------------------------------------------------------------------------------
'
' This code shows how to:
'   - replace icons in the executable with icons from an ico file which 
'     contains more than one image.
'   - add a 256x256 PNG-compressed icon (Vista icon)
'   - add or replace an Application manifest
'   - output the changes in the Resource Tree to a log file.
'
' To give you an idea of how this all works, we made this sample script and
' test application. When you installed Resorce Tuner Console on your computer,
' the setup program created the "Demo" folder under the RTC folder, with 
' the test application "DemoApp1.exe" in the "Demo\Src" folder. 
'
' The script will add or replace icons in demoapp1.exe with icons from the .ico
' and .png files from the "Demo\Src" folder. 
'
' The resulting file will be created in the directory named "Demo\Release"
' Check the log file "rtc.log" to see the Resource Tree changed.  
'
' Demonstrates the following:
'
' - PEFileProxy.OpenFileEx
' - PEFileProxy.Terminated
' - PEFileProxy.HasResources
' - PEFileProxy.CreateBackUp
' - PEFileProxy.SaveAsNewImage
' - PEFileProxy.PostDebugString
' - PEFileProxy.UpdateCheckSum
' - ResourcesProxy.ChangeIcon
' - ResourcesProxy.ChangeVistaIcon
' - ResourcesProxy.ChangeManifest
' - ResourcesProxy.SetLanguage
' - ResourcesProxy.SortGroupIcon
' - ResourcesProxy.ResourceTreeToLog
'
'------------------------------------------------------------------------------
Sub Main
  PEFileProxy.PostDebugString "Aktualisierung der Prüfsumme im PE Dateikopf ist aktiviert."
  PEFileProxy.UpdateCheckSum = True

  PEFileProxy.PostDebugString "Die Erstellung einer Sicherungskopie ist deaktiviert."
  PEFileProxy.CreateBackUp = False

  LangID = 0 ' Default
  CP     = ScriptUnit.CodePageFromLangID(LangID)

  PEFileProxy.PostDebugString "Opening the file and checking resources..."

  'Open file
  'Once the file is opened successfully, check if the file contains resources
  'If not, create resources

  If (PEFileProxy.OpenFileEx (".\demo\src\DemoApp1.exe", True)) Then

    ResourcesProxy.SetLanguage LangID, DELETE_IF_EXISTS

PEFileProxy.PostDebugString "Changing/adding the full XP icon set (9 icons)..."
ResourcesProxy.ChangeIcon "", LangID, CREATE_IF_NOT_EXIST, REPLACE_IF_ITEM_EXISTS, 
".\demo\src\xp_iconset.ico"

PEFileProxy.PostDebugString "Adding a 256 pix PNG Vista icon from the PNG file"
ResourcesProxy.ChangeVistaIcon "", LangID, 32, CREATE_IF_NOT_EXIST, REPLACE_IF_ITEM_EXISTS, 
".\demo\src\vista_256x256_32bit.png"

'Edit XML Manifest

    PEFileProxy.PostDebugString "Adding/editing XML Manifest..."
    ResourcesProxy.ChangeManifest EXE_MANIFEST, LangID, CREATE_IF_NOT_EXIST, 
".\demo\src\exe_manifest.xml"

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

    PEFileProxy.PostDebugString "Saving file as a new file..."
    PEFileProxy.SaveAsNewImage ".\demo\release\demoapp1.exe"

    PEFileProxy.PostDebugString "Closing this file..."
    PEFileProxy.CloseFile

  Else
    PEFileProxy.PostDebugString "Opening the file produced a fatal error."
  End If

End Sub
'------------------------------------------------------------------------------

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.

 

Die komplett illustrierte Schritt für Schritt Anleitung wie man Skripte benutzt

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