borderAndreaVB free resources for Visual Basic developersborder

AndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2008 Andrea Tincani
:: Strip out Strings of exe files

Author  

Ben Jones

Language  

VB5, VB6

Operating Systems  

Windows 95, 98,2000 and NT
Module
' This is a small little bit code that will rip out all the string in a file
' Start a new program and place this code in to the General Declarations select of the
' Form. Also you will need to add a command button to the form as well. Then press F5

Public Sub sDumpStrings(strFile As String, strTextFile As String, intMinSize As Integer)
    
    If Len(Dir(strFile)) = 0 Then Exit Sub
    Dim b() As Byte
    Dim hFile As Integer
    Dim bIsString As Boolean
    Dim i As Long
    Dim lngLen As Long
    Dim strLine As String
    Const strCompare = "[A-Z a-z 0-9,.!?@#$%]"
    hFile = FreeFile
    Open strFile For Binary As #hFile
    lngLen = LOF(hFile)
    ReDim b(1 To lngLen)
    Get #hFile, , b
    Close #hFile
     
    hFile = FreeFile
    Open strTextFile For Output As #hFile
     
    For i = 1 To lngLen
        If Chr(b(i)) Like strCompare Then
            If Chr(b(i + 1)) Like strCompare Then
                strLine = strLine & Chr(b(i))
            ElseIf i > 1 Then
                If Chr(b(i - 1)) Like strCompare Then
                    strLine = strLine & Chr(b(i))
                    If Len(strLine) > intMinSize Then
                        Print #hFile, strLine
                        Debug.Print strLine
                    End If
                    strLine = ""
                End If
            End If
        End If
    Next

    Close #hFile
    MsgBox "All done", vbInformation
    
End Sub
Usage
Private Sub Command1_Click()
    sDumpStrings "C:\Windows\Notepad.exe", "C:\Notepad.txt", 15 
    ' Change the filename if you like
    
End Sub

Private Sub Form_Load()
    Command1.Caption = "Strip out Strings"
    
End Sub
:: Navigation

Home

Files and Disks Tips

Previous Tip

Next Tip

:: Search this site
Google
:: Related Topics
icon 07-06-2006 Why does this file-listing module produce duplicate filenames? by s_climax
Partners: Il portale per lui e lei | Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2008 Andrea Tincaniborder