Hex Editor
Hex Editor - Binary File Editing Software for Windows

IFileDocument.FindAll Method

HHD Software - Hex Editor Serial Port Monitor USB Protocol Analyzer Network Monitor
 
 
 
< PreviousTopNext >
Declaration
Automation:
void  FindAll ( [in]   ref byte  pDataToFind, [in]   uint  data_size, [in]   IMultiSelection  pSelection, [in]   bool  ignore_case, [in]   IMultiSelection  pFound) ;
Native (C++):
HRESULT  FindAll ( [in]   unsigned char *  pDataToFind, [in]   unsigned long  data_size, [in]   IMultiSelection *  pSelection, [in]   VARIANT_BOOL  ignore_case, [in]   IMultiSelection *  pFound) ;
Parameters
pDataToFindPointer to a patterndata_sizePattern sizepSelectionMultiple Selection object, which contains ranges in which a pattern need to be locatedignore_caseTrue to ignore case, False to perform exact matching.pFoundMultiple Selection object, which contains, on method's return, all located ranges.
Return Value
S_OK or standard OLE error code.
Remarks
Locates all occurrences of a given pattern within a given multiple selection. You provide the function with an output Multiple Selection object pFound, in which it stores all located ranges. This object is automatically cleared before the operation begins. When the method returns, check the IMultiSelection.Empty property to see if there were any pattern occurrences. Complexity: linear-time, depending on the file's size and selection's complexity.
Examples

Searching all pattern occurrences

C#Copy Code
FileDocumentLib.FileDocument fdoc = new FileDocumentLib.FileDocument();
FileDocumentLib.IMultiSelection msel = fdoc.CreateEmptySelection();
FileDocumentLib.IMultiSelection mselOutput = fdoc.CreateEmptySelection();

fdoc.Open(@"c:\temp\file.txt");
msel.AddRange(0, fdoc.FileSize);  // We'll be searching in a whole file

byte[] pattern = new byte[] { 0x0d, 0x0a }; // EOL pattern
fdoc.FindAll(ref pattern[0], pattern.Length, msel, false, mselOutput);
if (!mselOutput.Empty) // check if there are any matches
  fdoc.Copy(mselOutput,false);  // copy them to the Clipboard
    
< PreviousTopNext >
Copyright © 2012 HHD Software. All rights reserved.