Hex Editor - Binary File Editing Software for Windows
Working with Document Object
This section illustrates several document object usage scenarios. All examples in this section suppose that you have a valid reference to a file document object, as described in Creating Document Object section.
All actions that lead to document modification create new operations in document's operation history.
Before you start using the newly created document object, you must initialize it.
If you want to associate a document object with any existing file, call the IFileDocument.Open method. If you want to associate a document object with an empty file, call the IFileDocument.New method. After that, the document object enters the initialized state and is ready to process further requests.
To open a volume, call the IFileDocument.OpenVolume method. You may also open a physical disk (IFileDocument.OpenPhysicalDisk), process memory (IFileDocument.OpenProcess) and physical memory (IFileDocument.OpenPhysicalMemory).
The IFileDocument.Close method is used to close the document object. The object enters an uninitialized state after it is closed. All changes made to the document are silently discarded.
You don't need to explicitly call this method as it is automatically called when object is destroyed. Although, if you are going to reuse the document object (that it, call Open or New method again), this method must be called.
The IFileDocument.Modified property is TRUE if the document has been modified and FALSE otherwise. It can be used to determine whether the document must be saved. To save a document, call the IFileDocument.Save or IFileDocument.SaveAs methods. The first method overwrites the existing file while the second method creates a copy of the file.
If the document object was initialized with a call to IFileDocument.New method, IFileDocument.Save method cannot be called until you call IFileDocument.SaveAs method that also updates the IFileDocument.FileName property. IFileDocument.FileName property contains the full path to the file this document is currently representing.
User Interface Analogue: Saving Documents.
User Interface Analogue: Data Modification.
Several file document object's methods are used to insert data into the file. All insert methods increase the file's size and shift remaining data to free up space for inserted data.
User Interface Analogue: Data Modification and Insert command.
User Interface Analogue: Delete command.
Unlike Insert group of methods, Fill methods overwrite original file's data with new data.
User Interface Analogue: Fill command.
The IFileDocument.Replace method is used to replace a single occurrence of the pattern with another pattern. The powerful IFileDocument.ReplaceAll method automatically locates all occurrences of specified pattern in a file and replace them with another pattern.
User Interface Analogue: Statistics Tool Window.
The IFileDocument.PutFile method is used to put the contents of a disk file to the current document.
User Interface Analogue: Insert File command.
The read-write IFileDocument.FileSize property can be used to query or change the file's size. If you use it to change the size, new operation in operation history is created.
User Interface Analogue: Change File Size command.
The IFileDocument.CanUndo and IFileDocument.CanRedo properties are TRUE if IFileDocument.Undo and IFileDocument.Redo methods may be called for a document correspondingly. The IFileDocument.Undo method undoes the previous operation, placing it into the operation tail. IFileDocument.Redo method makes the first operation from operation tail a current operation.
User Interface Analogue: File » Create Patch… command.
The IFileDocument.PasteText method is used to paste text from the Clipboard as it is, either in ANSI or UNICODE. You can also use the IFileDocument.PasteText2 method to paste the text from the Clipboard and convert it to a given encoding.
Four methods, IFileDocument.BitwiseOp, IFileDocument.ArithmeticOp, IFileDocument.ShiftOp and IFileDocument.CaseOp, are used to perform bitwise, arithmetic, shift and case change operations correspondingly.
The following methods accept regular expression as their parameters: IFileDocument.FindRegExp2, IFileDocument.FindAllRegExp2, IFileDocument.ReplaceAllRegExp2 and IFileDocument.PatternStatisticsRegExp2.