Jump to content

Does AutoIt have something built-in like VBScript's FreeMem?


Recommended Posts

Well, I will try to better explain what is happening with me- I am trying to make a very long script, which analyzes the hexadecimal dump of each file's header (get binary/hex bytes in the beginning of file), and compares it with

an internal set (database) of pre-defined conditional rules.

[PSEUDO-CODE]

{

Dim header

header = get(dump) file header

If header = "000ff00aa" Then file = "PDF"

If header = "aff0ee000h" Then file = "CHM"

(...)

Sometimes, files downloaded in eMule (ed2k) are fakes - porno movies with wrong extension (iso, pdf, zip). When I try to open them and I got an error message, I hex-edit them and there it is - the AVI header!! Renaming file to avi, allows me to see the (porno) movie (damn, so many GB of download traffic wasted for nothing!!)...

That's the reason why decided to create (or, at last, try to create) this script... It is very big, very CPU and RAM consumer, and so I need to make pauses (Sleep) and I also found it is need to clean RAM cyclically...

Here it is (NOTE - MsgBox's and Comments are in Portuguese language - I am Portuguese... If you really find useful, you and/or me can translate it to English or other language...):

#include <Array.au3>
#include <File.au3>
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$aviso = MsgBox (16+1, "Muita Atenção!!!!", "ATENÇÃO!!: Este script exige muito das capacidades globais da CPU & RAM!!..." & Chr(13) & Chr(13) & "Não deve correr outros processos ""pesados"" em simultâneo!!..." & Chr(13) & Chr(13) & _ 
"O ScreenSaver tem que ser desactivado, e o monitor não pode ser desligado, enquanto este script estiver a correr!!..." & Chr(13) & Chr(13) & _ 
"O melhor conselho é: deixe o PC trabalhar sozinho; faça uma pausa; vá beber um café... Volte a utilisar o PC só quando este script terminar ;)")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
If $aviso = 2 Then
    MsgBox(48, "Nada Feito!", "A acção foi cancelada...")
    Exit
EndIf
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$path = InputBox("Path...", "Detector de FAKES..." & Chr(13) & Chr(13) & "Qual o directório = pasta (path = caminho)?" & Chr(13) & Chr(13) & "Exemplo:" & Chr(13) & "C:\Directorio", "", "", 240, 190)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
If @error <> 0 Then
    MsgBox(48, "Nada Feito!", "A acção foi cancelada...")
    Exit
EndIf
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Dim $dir, $mask, $dont_recurse, $dump, $return_dirs
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
RecurseDir($dir, $mask, $dont_recurse = False, $dump = "", $return_dirs = False)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Func RecurseDir($dir, $mask, $dont_recurse = False, $dump = "", $return_dirs = False)
    ;debug(@ScriptLineNumber & ": " & "func: RecurseDir " & $dir)

    Dim $n_dirnames[333333]  ; maximum number of directories which can be scanned
    Local $n_dircount = 0    ; ^ could be set much higher, if required
    Local $n_file
    Local $n_search
    Local $n_tfile
    Local $file_array
    Local $filenames
    Local $filecount
    Local $dircount = 1
    Local $msg = "error" 

    ; if there was an "\" on the end of the given directory, remove that..
    If StringRight($dir, 1) = "\"  Then $dir = StringTrimRight($dir, 1)

    $n_dirnames[$dircount] = $dir

    If Not FileExists($dir) Then Return 0

    While $dircount > $n_dircount ; keep on looping until all directories are scanned..

        $n_dircount += 1
        $n_search = FileFindFirstFile($n_dirnames[$n_dircount] & "\*.*")

        While 1  ; find all subdirs in this directory and store them in a array..
            $n_file = FileFindNextFile($n_search)
            If @error Then ExitLoop
            ; skip directory references..
            If $n_file = "."  Or $n_file = ".."  Then ContinueLoop

            $n_tfile = $n_dirnames[$n_dircount] & "\" & $n_file

            ; if it's a directory, add it to the list of directories to be processed..
            If StringInStr(FileGetAttrib($n_tfile), "D") And Not $dont_recurse Then
                $dircount += 1
                $n_dirnames[$dircount] = $n_tfile
            EndIf
        WEnd
        FileClose($n_search)

        ; multiple masks..
        If StringInStr($mask, ",", 2) Then
            $mask_array = StringSplit($mask, ",")
        Else ; or else create a dummy array..
            Dim $mask_array[2] = [1, $mask]
        EndIf

        ; loop through the array of masks..
        For $mask_c = 1 To $mask_array[0]
            ; find all files that match this mask..
            $n_search = FileFindFirstFile($n_dirnames[$n_dircount] & "\" & $mask_array[$mask_c])
            If $n_search = -1 Then ContinueLoop

            While 1
                $n_file = FileFindNextFile($n_search)
                If @error Then ExitLoop ; end of dir
                If $n_file = "."  Or $n_file = ".."  Then ContinueLoop

                $n_tfile = $n_dirnames[$n_dircount] & "\" & $n_file
                If Not StringInStr(FileGetAttrib($n_tfile), "D") Then
                    $filecount += 1
                    $filenames &= $n_tfile & @LF
                EndIf
            WEnd
            FileClose($n_search)
        Next
    WEnd

    ; flip to a string and back to remove extraneous entries
    ; this is quicker than redimming on every loop
    If $return_dirs Then
        $tmp_str = ""
        $i = 1
        While $n_dirnames[$i] <> ""
            $tmp_str &= $n_dirnames[$i] & "|" 
            $i += 1
        WEnd
        $tmp_str = StringTrimRight($tmp_str, 1)
        $n_dirnames = StringSplit($tmp_str, "|")
        Return $n_dirnames
    EndIf

    $filenames = StringTrimRight($filenames, 1)
    If $filenames = "" Then Return 0
    $file_array = StringSplit($filenames, @LF)

    ; dump results to a file..
    If $dump Then
        $dump_file = FileOpen($dump, 2)
        FileWrite($dump_file, $filenames)
        FileClose($dump_file)
    EndIf
    Return ($file_array)
EndFunc   ;==>RecurseDir
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Dim $dir_recursivo
$dir_recursivo = RecurseDir($path, "*.*")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
If FileExists(@DesktopDir & "\OK.csv") Then
    FileDelete(@DesktopDir & "\OK.csv")
ElseIf FileExists(@DesktopDir & "\Fakes ou Desconhecidos.csv") Then
    FileDelete(@DesktopDir & "\Fakes ou Desconhecidos.csv")
EndIf



FileWrite(@DesktopDir & "\OK.csv", "Path" & "," & "Extensão" & "," & "Tipo de Ficheiro" & Chr(13))

FileWrite(@DesktopDir & "\Fakes ou Desconhecidos.csv", "Path" & "," & "Extensão" & Chr(13))




For $n = 1 To $dir_recursivo[0]
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    Dim $path_split, $szDrive, $szDir, $szFName, $szExt
    $path_split = _PathSplit($dir_recursivo[$n], $szDrive, $szDir, $szFName, $szExt)


    $abrir_ficheiro = FileOpen($dir_recursivo[$n], 16)
    $ler_ficheiro = FileRead($abrir_ficheiro)


    Switch $szExt
        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        Case ".exe"     ;;; EXE ;;;
            If BinaryMid($ler_ficheiro, 1, 2) = "MZ"  Then
                FileWrite(@DesktopDir & "\OK.csv", $dir_recursivo[$n] & "," & $szExt & "," & "Ficheiro executável de MS-DOS/Windows" & Chr(13))
            Else
                FileWrite(@DesktopDir & "\Fakes ou Desconhecidos.csv", $dir_recursivo[$n] & "," & $szExt)
            EndIf
            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        Case ".zip"     ;;; ZIP ;;;
            If BinaryMid($ler_ficheiro, 1, 2) = "PK"  Then
                FileWrite(@DesktopDir & "\OK.csv", $dir_recursivo[$n] & "," & $szExt & "," & "Ficheiro ZIP (compactado=comprimido)" & Chr(13))
            Else
                FileWrite(@DesktopDir & "\Fakes ou Desconhecidos.csv", $dir_recursivo[$n] & "," & $szExt)
            EndIf
            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        Case ".chm"      ;;; CHM ;;;
            If BinaryMid($ler_ficheiro, 1, 4) = "ITSF"  Then
                FileWrite(@DesktopDir & "\OK.csv", $dir_recursivo[$n] & "," & $szExt & "," & "Ficheiro CHM (Help - HTML Compilado)" & Chr(13))
            Else
                FileWrite(@DesktopDir & "\Fakes ou Desconhecidos.csv", $dir_recursivo[$n] & "," & $szExt)
            EndIf
            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        Case ".rar"     ;;; RAR ;;;
            If BinaryMid($ler_ficheiro, 1, 4) = "Rar!"  Then
                FileWrite(@DesktopDir & "\OK.csv", $dir_recursivo[$n] & "," & $szExt & "," & "Ficheiro RAR (compactado=comprimido)" & Chr(13))
            Else
                FileWrite(@DesktopDir & "\Fakes ou Desconhecidos.csv", $dir_recursivo[$n] & "," & $szExt)
            EndIf
            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        Case ".wri"     ;;; WRI ;;;
            If Hex(BinaryMid($ler_ficheiro, 1, 6)) = "31BE000000AB"  Then
                FileWrite(@DesktopDir & "\OK.csv", $dir_recursivo[$n] & "," & $szExt & "," & "Ficheiro WRI (Write Document)" & Chr(13))
            Else
                FileWrite(@DesktopDir & "\Fakes ou Desconhecidos.csv", $dir_recursivo[$n] & "," & $szExt)
            EndIf
            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        Case ".wmv"     ;;; WMV ;;;
            If Hex(BinaryMid($ler_ficheiro, 1, 6)) = "3026B2758E66"  Then
                FileWrite(@DesktopDir & "\OK.csv", $dir_recursivo[$n] & "," & $szExt & "," & "Ficheiro WMV (Windows Media Video)" & Chr(13))
            Else
                FileWrite(@DesktopDir & "\Fakes ou Desconhecidos.csv", $dir_recursivo[$n] & "," & $szExt)
            EndIf
            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        Case ".pdf"     ;;; PDF ;;;
            If BinaryMid($ler_ficheiro, 1, 7) = "%PDF-1."  Then
                FileWrite(@DesktopDir & "\OK.csv", $dir_recursivo[$n] & "," & $szExt & "," & "Ficheiro PDF" & Chr(13))
            Else
                FileWrite(@DesktopDir & "\Fakes ou Desconhecidos.csv", $dir_recursivo[$n] & "," & $szExt)
            EndIf
            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        Case ".rtf"     ;;; RTF ;;;
            If BinaryMid($ler_ficheiro, 1, 7) = "{\rtf1\"  Then
                FileWrite(@DesktopDir & "\OK.csv", $dir_recursivo[$n] & "," & $szExt & "," & "Ficheiro RTF (Ritch Text Format)" & Chr(13))
            Else
                FileWrite(@DesktopDir & "\Fakes ou Desconhecidos.csv", $dir_recursivo[$n] & "," & $szExt)
            EndIf
            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        Case ".pdb"     ;;; PDB ;;;
            Select
                Case StringInStr(BinaryToString(BinaryMid($ler_ficheiro, 1, 256)), "SDocSilX") ;;; PDB de iSilo ;;;
                    FileWrite(@DesktopDir & "\OK.csv", $dir_recursivo[$n] & "," & $szExt & "," & "Ficheiro PDB de iSilo" & Chr(13))
                Case StringInStr(BinaryToString(BinaryMid($ler_ficheiro, 1, 256)), "TEXtREAd") ;;; PDB de iSilo ;;;
                    FileWrite(@DesktopDir & "\OK.csv", $dir_recursivo[$n] & "," & $szExt & "," & "Ficheiro PDB de iSilo" & Chr(13))
                Case StringInStr(BinaryToString(BinaryMid($ler_ficheiro, 1, 256)), "ToGoToGo") ;;; PDB de iSilo ;;;
                    FileWrite(@DesktopDir & "\OK.csv", $dir_recursivo[$n] & "," & $szExt & "," & "Ficheiro PDB de iSilo" & Chr(13))
                Case Else
                    FileWrite(@DesktopDir & "\Fakes ou Desconhecidos.csv", $dir_recursivo[$n] & "," & $szExt)
            EndSelect
            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        Case ".djvu"  Or ".djv"     ;;; DJVU = DJV ;;;
            If StringInStr(BinaryToString(BinaryMid($ler_ficheiro, 1, 256)), "DJVMDIRM") Then
                FileWrite(@DesktopDir & "\OK.csv", $dir_recursivo[$n] & "," & $szExt & "," & "Ficheiro DJVU" & Chr(13))
            Else
                FileWrite(@DesktopDir & "\Fakes ou Desconhecidos.csv", $dir_recursivo[$n] & "," & $szExt)
            EndIf
            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        Case ".mov"    ;;; MOV ;;;
            Select
                Case StringInStr(BinaryToString(BinaryMid($ler_ficheiro, 1, 112)), "moov")
                    FileWrite(@DesktopDir & "\OK.csv", $dir_recursivo[$n] & "," & $szExt & "," & "Ficheiro MOV (Apple Quick Time Movie)" & Chr(13))
                Case StringInStr(BinaryToString(BinaryMid($ler_ficheiro, 1, 112)), "mdat")
                    FileWrite(@DesktopDir & "\OK.csv", $dir_recursivo[$n] & "," & $szExt & "," & "Ficheiro MOV (Apple Quick Time Movie)" & Chr(13))
                Case Else
                    FileWrite(@DesktopDir & "\Fakes ou Desconhecidos.csv", $dir_recursivo[$n] & "," & $szExt)
            EndSelect
            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        Case ".mht"       ;;; MHT ;;;
            Select
                Case StringInStr(BinaryToString(BinaryMid($ler_ficheiro, 1, 256)), "Microsoft Internet Explorer")
                    FileWrite(@DesktopDir & "\OK.csv", $dir_recursivo[$n] & "," & $szExt & "," & "Ficheiro MHT (MIME-HTML)" & Chr(13))
                Case Else
                    FileWrite(@DesktopDir & "\Fakes ou Desconhecidos.csv", $dir_recursivo[$n] & "," & $szExt)
            EndSelect
            ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


    EndSwitch


    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    Sleep(3000)
Next


MsgBox(64, "Fim!", "Veja os ficheiro ""OK.csv"" e ""Fakes ou Desconhecidos.csv"", localizado no seu Ambiente de Trabalho (Desktop).")

I also made a Google Search, looking for:

*) ActiveX=COM Component to clean RAM (...ObjCreate...)

*) Command-line RAM Cleaner (...Run @ComSpec...)

But I still feeling lost and confused...

I hope anyone can help :P

Thanks.

Regards.

MLMK - my blogging craziness...
Link to comment
Share on other sites

Well there is a UDF written that will free some memory, but you cannot specify how much.

;===============================================================================
;
; AutoIt Version:   3.1.1++
; Description:      Reduce memory usage of process ID (PID) given.
; Syntax:           _ReduceMemory( [ $iPID = -1 [, $hPsAPIdll = 'psapi.dll' [, $hKernel32dll = 'kernel32.dll' ] ] ])
; Parameter(s):     $iPID - PID of process to reduce memory. If -1 reduce self memory usage.
;                   $hPsAPIdll - Optional handle to psapi.dll.
;                   $hKernel32dll - Optional handle To kernel32.dll.
; Requirement(s):   psapi.dll (Doesn't come with WinNT4 by default)
; Notes:            If @OSVersion = 'WIN_NT4' Then FileInstall('psapi.dll', @SystemDir & '\psapi.dll')
; Author:           w0uter ( w0uter88 [at] hotmail [dot] com / http://www.autoitscript.com/forum/index.php?showuser=4347 )
; Modified by:      Saunders (admin@therks.com)
;
;===============================================================================

Func _ReduceMemory($iPID = -1, $hPsAPIdll = 'psapi.dll', $hKernel32dll = 'kernel32.dll')
    If $iPID <> -1 Then
        Local $aHandle = DllCall($hKernel32dll, 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $iPID)
        Local $aReturn = DllCall($hPsAPIdll, 'int', 'EmptyWorkingSet', 'long', $aHandle[0])
        DllCall($hKernel32dll, 'int', 'CloseHandle', 'int', $aHandle[0])
    Else
        Local $aReturn = DllCall($hPsAPIdll, 'int', 'EmptyWorkingSet', 'long', -1)
    EndIf

    Return $aReturn[0]
EndFunc

That's the one I have.

Link to comment
Share on other sites

First off, I can't find any documentation for this FreeMem function on anything dealing with vbscript.

Secondly, i'm pretty sure this function only forces X mb of ram into the pagefile, and this by no means will enhance performance.

Link to comment
Share on other sites

weaponx - in fact, the FreeMem function is almost always ignored in VBS books... If you want to learn more, do a Google Search:

"FreeMem" +"Space" +"vbscript"

mrbound007 - "Memory Fusion" is superb!!! Thank you very much!!!

to all of you - thank you very much for replying!!!!!

Regards.

MLMK - my blogging craziness...
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...