Имя пользователя:
Пароль:  
Помощь | Регистрация | Забыли пароль?  

Показать сообщение отдельно

Googler


Сообщения: 3665
Благодарности: 1563

Профиль | Отправить PM | Цитировать


для чтения инфы из RAR-файлов можно использовать UnRar.dll с оффсайта:
Код: Выделить весь код
#include <Array.au3>
#include <File.au3>

$sRoot = "D:\" ; Каталог с архивами, оконечный слэш обязателен
$aFilesAll = _FileListToArray($sRoot,"*.rar",1)

Dim $aFilesPwd[1], $aFiles[1]
For $i=1 To $aFilesAll[0]
    If _RarIsEncrypt($sRoot & $aFilesAll[$i]) Then
        $aFilesPwd[0]+=1
        ReDim $aFilesPwd[$aFilesPwd[0]+1]
        $aFilesPwd[$aFilesPwd[0]] = $sRoot & $aFilesAll[$i]
    Else
        $aFiles[0]+=1
        ReDim $aFiles[$aFiles[0]+1]
        $aFiles[$aFiles[0]] = $sRoot & $aFilesAll[$i]
    EndIf
Next

_ArrayDisplay($aFiles, "Список незашифрованных архивов")
_ArrayDisplay($aFilesPwd, "Список зашифрованных архивов")

Func _RarIsEncrypt($sFile)
    Local $hDll = DllOpen(@ProgramFilesDir &"\WinRAR\unrar.dll")
    If $hDll=-1 Then Return SetError(1, 0, True)

    Local Const $ERAR_END_ARCHIVE = 10
    Local Const $ERAR_UNKNOWN     = 21
    Local Const $tzRAROpenArchiveData = "ptr pArcName;uint OpenMode;uint OpenResult;ptr pCmtBuf;uint CmtBufSize;uint CmtSize;uint CmtState"
    Local Const $tzRARHeaderData = "char ArcName[260];char FileName[260];uint Flags;uint PackSize;uint UnpSize;uint HostOS;uint FileCRC;uint FileTime;uint UnpVer;uint Method;uint FileAttr;ptr pCmtBuf;uint CmtBufSize;uint CmtSize;uint CmtState"

    Local $iFile = StringLen($sFile), $aRAR, $aRet, $iRes = False
    Local $tRAROpenArchiveData = DllStructCreate($tzRAROpenArchiveData)
    Local $pRAROpenArchiveData = DllStructGetPtr($tRAROpenArchiveData)
    Local $tRARHeaderData = DllStructCreate($tzRARHeaderData)
    Local $pRARHeaderData = DllStructGetPtr($tRARHeaderData)
    Local $tArcName = DllStructCreate("char ArcName["& $iFile+1 &"]")
    Local $pArcName = DllStructGetPtr($tArcName)

    DllStructSetData($tArcName, "ArcName", $sFile)
    DllStructSetData($tRAROpenArchiveData, "pArcName", $pArcName)

    $aRAR = DllCall($hDll, "hwnd", "RAROpenArchive", "ptr", $pRAROpenArchiveData)
    If $aRAR[0]=0 Then
        DllClose($hDll)
        Return SetError(2, DllStructGetData($tRAROpenArchiveData,"OpenResult"), True)
    EndIf

    $aRet = DllCall($hDll, "int", "RARReadHeader", "hwnd", $aRAR[0], "ptr", $pRARHeaderData)
    While $aRet[0]<>$ERAR_END_ARCHIVE
        If ($aRet[0]=$ERAR_UNKNOWN) Or BitAND(0x04, DllStructGetData($tRARHeaderData,"Flags")) Then
            $iRes = True
            ExitLoop
        EndIf
        $aRet = DllCall($hDll, "int", "RARReadHeader", "hwnd", $aRAR[0], "ptr", $pRARHeaderData)
    WEnd

    DllCall($hDll, "int", "RARCloseArchive", "hwnd", $aRAR[0])
    DllClose($hDll)
    Return $iRes
EndFunc
Это сообщение посчитали полезным следующие участники:

Отправлено: 06:43, 27-03-2009 | #6