AllExperts > Delphi 
Search      
Delphi
Volunteer
Answers to thousands of questions
 Home · More Delphi Questions · Answer Library  · Encyclopedia ·
More Delphi Answers
Question Library

Ask a question about Delphi
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Randy Sill
Expertise
Turbo Pascal and Delphi developer since 1986. Strengths - UI, Windows API, Database, SQL, Internet, Threading, NT Services.

Experience
Turbo Pascal and Delphi developer since 1986.

Education/Credentials
Delphi 5 Certification, Borland

Awards and Honors
2005 Indiana IT/Software Million Dollar Award, Key Technical Contributor

 
   

You are here:  Experts > Computing/Technology > Delphi Programming > Delphi > Extracting strings from *.exe written in Delphi

Delphi - Extracting strings from *.exe written in Delphi


Expert: Randy Sill - 10/28/2009

Question
For any given Delphi written *.exe, how can I extract the string values compiled in the *.exe?

TIA

Answer
I have in the past written a simple Delphi application that opens for read the exe file and scans for ASCII characters in the normal range with a minimum lenght and dumps them into a string list.  A parameter can be placed on the application to determine what this minimum length is so you can filter out a lot of the junk that may appear.

Here is an example Scan:

procedure TForm1.Button1Click(Sender: TObject);
var
 FileStream: TFileStream;
 CharIn: char;
 MinLen: integer;
 CurrValue: string;
 i: integer;
 MaxPos: integer;
begin
 MinLen := StrToInt(Edit2.Text);
 CurrValue := '';
 FileStream := TFileStream.Create(Edit1.Text, fmOpenRead);
 try
   MaxPos := FileStream.Size;
   for i := 1 to MaxPos do begin
     FileStream.Read(CharIn, 1);
     if CharIn in [#32..#126] then
       CurrValue := CurrValue + CharIn
     else
       if Length(CurrValue) >= MinLen then begin
         Memo1.Lines.Add(CurrValue);
         CurrValue := '';
       end;
   end;
 finally
   FileStream.Free;
 end;
end;

Add to this Answer   Ask a Question


 
User Agreement | Privacy Policy | Kids' Privacy Policy | Help
Copyright  © 2008 About, Inc. AllExperts, AllExperts.com, and About.com are registered trademarks of About, Inc. All rights reserved.