Sign in to follow this  
Followers 0
Watt

UNRAR.DLL and AutoIT

20 posts in this topic

Hi to Alls!

I need some help useing unrar.dll in autoit. I've downloaded the needed software (unrar) and i've seen the examples (VB) but the code may be wrong or something, bcoz it hangs up... ;)

Here is the sample code, just the opening archive part:

#include "array.au3"
#include "string.au3"

Const $ERAR_END_ARCHIVE = 10
Const $ERAR_NO_MEMORY = 11
Const $ERAR_BAD_DATA = 12
Const $ERAR_BAD_ARCHIVE = 13
Const $ERAR_UNKNOWN_FORMAT = 14
Const $ERAR_EOPEN = 15
Const $ERAR_ECREATE = 16
Const $ERAR_ECLOSE = 17
Const $ERAR_EREAD = 18
Const $ERAR_EWRITE = 19
Const $ERAR_SMALL_BUF = 20
 
Const $RAR_OM_LIST = 0
Const $RAR_OM_EXTRACT = 1
 
Const $RAR_SKIP = 0
Const $RAR_TEST = 1
Const $RAR_EXTRACT = 2
 
Const $RAR_VOL_ASK = 0
Const $RAR_VOL_NOTIFY = 1

$rar_open_str           = "char[260];uint;uint;char[16384];uint;uint;uint"
$rar_open               = DllStructCreate($rar_open_str)
$rar_header_str         = "char[260];char[260];uint;uint;uint;uint;uint;uint;uint;uint;uint;char[16384];uint;uint;uint"
$rar_header             = DllStructCreate($rar_header_str)

DllStructSetData($rar_open,1,'c:\test1.rar')
DllStructSetData($rar_open,2,$RAR_OM_EXTRACT)
DllStructSetData($rar_open,3,0)
DllStructSetData($rar_open,4,_StringRepeat(" ",16384))
DllStructSetData($rar_open,5,16384)
DllStructSetData($rar_open,6,0)
DllStructSetData($rar_open,7,0)

$rar_handle = DllCall("unrar.dll","int","RAROpenArchive","ptr",DllStructGetPtr($rar_open))

_ArrayDisplay($rar_handle,"")

Just test it out...

THX

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I have not looked at it all but unless your script is in the include folder it will not find the included files.

Try

#include <array.au3>

#include <string.au3>

Edited by BigDod


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

I use Scite, the includes are ok, but if i use the dllcall func it hangs the rutin. May be the params are not good?

Share this post


Link to post
Share on other sites

Yes, i've downloaded the full unrar.dll pack from rarlab! From the doc the data structure would be good but the dll hangs with these params. Sorry.

Share this post


Link to post
Share on other sites

struct RARHeaderData

{

char ArcName[260];

char FileName[260];

unsigned int Flags;

unsigned int PackSize;

unsigned int UnpSize;

unsigned int HostOS;

unsigned int FileCRC;

unsigned int FileTime;

unsigned int UnpVer;

unsigned int Method;

unsigned int FileAttr;

char *CmtBuf;

unsigned int CmtBufSize;

unsigned int CmtSize;

unsigned int CmtState;

};

struct RAROpenArchiveData

{

char *ArcName;

unsigned int OpenMode;

unsigned int OpenResult;

char *CmtBuf;

unsigned int CmtBufSize;

unsigned int CmtSize;

unsigned int CmtState;

};


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

This may be the incorrect way to do this, but don't have time to test and correct, on my way out the door.

CODE

#include <array.au3>

#include <string.au3>

Const $ERAR_END_ARCHIVE = 10

Const $ERAR_NO_MEMORY = 11

Const $ERAR_BAD_DATA = 12

Const $ERAR_BAD_ARCHIVE = 13

Const $ERAR_UNKNOWN_FORMAT = 14

Const $ERAR_EOPEN = 15

Const $ERAR_ECREATE = 16

Const $ERAR_ECLOSE = 17

Const $ERAR_EREAD = 18

Const $ERAR_EWRITE = 19

Const $ERAR_SMALL_BUF = 20

Const $RAR_OM_LIST = 0

Const $RAR_OM_EXTRACT = 1

Const $RAR_SKIP = 0

Const $RAR_TEST = 1

Const $RAR_EXTRACT = 2

Const $RAR_VOL_ASK = 0

Const $RAR_VOL_NOTIFY = 1

$rar_open_arcname = DllStructCreate("char[260]")

DllStructSetData($rar_open_arcname,1,'c:\test1.rar')

if @error Then

MsgBox(0,"","Error in DllStructCreate " & @error);

exit

endif

$rar_open_cmtbuf = DllStructCreate("char[16384]")

DllStructSetData($rar_open_cmtbuf,1,_StringRepeat(" ",16384))

if @error Then

MsgBox(0,"","Error in DllStructCreate " & @error);

DllStructDelete($rar_open_arcname)

exit

endif

$rar_open_str = DllStructCreate("ptr;uint;uint;ptr;uint;uint;uint")

if @error Then

MsgBox(0,"","Error in DllStructCreate " & @error);

DllStructDelete($rar_open_arcname)

DllStructDelete($rar_open_cmtbuf)

exit

endif

DllStructSetData($rar_open_str,1,DllStructGetPtr($rar_open_arcname))

DllStructSetData($rar_open_str,2,$RAR_OM_EXTRACT)

DllStructSetData($rar_open_str,3,0)

DllStructSetData($rar_open_str,4,DllStructGetPtr($rar_open_cmtbuf))

DllStructSetData($rar_open_str,5,16384)

DllStructSetData($rar_open_str,6,0)

DllStructSetData($rar_open_str,7,0)

$rar_hdr_cmtbuf = DllStructCreate("char[16384]")

if @error Then

MsgBox(0,"","Error in DllStructCreate " & @error);

DllStructDelete($rar_open_arcname)

DllStructDelete($rar_open_cmtbuf)

DllStructDelete($rar_open_str)

exit

endif

$rar_header_str = DllStructCreate("char[260];char[260];uint;uint;uint;uint;uint;uint;uint;uint;uint;ptr;uint;uint;uint")

if @error Then

MsgBox(0,"","Error in DllStructCreate " & @error);

DllStructDelete($rar_open_arcname)

DllStructDelete($rar_open_cmtbuf)

DllStructDelete($rar_open_str)

DllStructDelete($rar_hdr_cmtbuf)

exit

endif

DllStructSetData($rar_header_str,12,DllStructGetPtr($rar_hdr_cmtbuf))

$rar_handle = DllCall(@ProgramFilesDir & "\UnrarDll\unrar.dll","int","RAROpenArchive","ptr",DllStructGetPtr($rar_open_str))

_ArrayDisplay($rar_handle,"")

DllStructDelete($rar_open_arcname)

DllStructDelete($rar_open_cmtbuf)

DllStructDelete($rar_open_str)

DllStructDelete($rar_hdr_cmtbuf)

DllStructDelete($rar_header_str)

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

For first run it has not hunged!!! I am testing the results!!! May be the success of the structure declaration was the error????

I have not looked at it all but unless your script is in the include folder it will not find the included files.

Try

#include <array.au3>

#include <string.au3>

Sorry i read the help!!! THX :">

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

The mistake was the name of the file!!!! It was a "char[260]" type and not a pointer in the third ($str) structure!!! Thank u all the helps!!! But the topic still open until the unrar.dll project!?

THANK U!

Edited by Watt

Share this post


Link to post
Share on other sites

Hi to ALL!

Here is the second problem: The header calling part! May be the structure is wrong, may be not!!! The struct. creating rules are not problems (creating etc)! THANX for help advance!

#include <array.au3>
#include <string.au3>


;RAROpenArchive structure
$open_archive_name      = "char[256]"
$open_name              = DllStructCreate($open_archive_name)
$open_buffer_structure  = "char[16384]"
$open_buffer            = DllStructCreate($open_buffer_structure)
$open_type              = "ptr;uint;uint;ptr;uint;uint;uint"
$open_data              = DllStructCreate($open_type)


;RARHeader structure
$head_archive_name      = _StringRepeat("char[256];",260)
$head_archive_name      = StringTrimRight($head_archive_name,1)
$head_name              = DllStructCreate($head_archive_name)
$head_filename          = _StringRepeat("char[256];",260)
$head_filename          = StringTrimRight($head_filename,1)
$head_file              = DllStructCreate($head_filename)

$head_buffer_structure  = "char[16384]"
$head_buffer            = DllStructCreate($head_buffer_structure)
$head_type              = "ptr;ptr;uint;uint;uint;uint;uint;uint;uint;uint;uint;uint;uint;uint;uint"
$head_data              = DllStructCreate($head_type)



DllStructSetData($open_name,1,"test.rar")
DllStructSetData($open_data,1,DllStructGetPtr($open_name))
DllStructSetData($open_data,2,1)
DllStructSetData($open_data,3,0)
DllStructSetData($open_data,4,DllStructGetPtr($open_buffer))
DllStructSetData($open_data,5,16384)
DllStructSetData($open_data,6,16384)
DllStructSetData($open_data,7,0)

DllStructSetData($head_data,1,DllStructGetPtr($head_name))
DllStructSetData($head_data,2,DllStructGetPtr($head_file))
DllStructSetData($head_data,12,DllStructGetPtr($head_buffer))
DllStructSetData($head_data,13,0)


$xxx = DllCall("unrar.dll","int","RAROpenArchive","ptr",DllStructGetPtr($open_data))
_ArrayDisplay($xxx,"")
$aa     = DllStructGetData($open_data,1)
$bb     = DllStructGetData($open_data,2)
$cc     = DllStructGetData($open_data,3)
$dd     = DllStructGetData($open_data,4)
$ee     = DllStructGetData($open_data,5)
$ff     = DllStructGetData($open_data,6)
$gg     = DllStructGetData($open_data,7)

msgbox(0,"","aa: " & $aa & @CRLF & _
            "bb: " & $bb & @CRLF & _
            "cc: " & $cc & @CRLF & _
            "dd: " & $dd & @CRLF & _
            "ee: " & $ee & @CRLF & _
            "ff: " & $ff & @CRLF & _
            "gg: " & $gg)


$yyy = DllCall("unrar.dll","int","RARReadHeader","int",$xxx[0],"ptr",DllStructGetPtr($head_data))
_ArrayDisplay($yyy,"")
$zzz = DllCall("unrar.dll","int","RARProcessFile","int",$xxx[0],"int",2,"char","","char","")
_ArrayDisplay($zzz,"")
$www = DllCall("unrar.dll","int","RARCloseArchive","int",$xxx[0])
_ArrayDisplay($zzz,"")


;free the struct
DllStructDelete($open_data)
DllStructDelete($open_name)
DllStructDelete($open_buffer)

DllStructDelete($head_name)
DllStructDelete($head_file)
DllStructDelete($head_buffer)
DllStructDelete($head_data)

Share this post


Link to post
Share on other sites

Hello all,

Did anyone finally managed to write a working version of it?

Share this post


Link to post
Share on other sites

#11 ·  Posted

Hello all,

Did anyone finally managed to write a working version of it?

Yes really is there any news on this ?


There is a hex ( 31303030303030 ) reasons i love AutoIt !

Share this post


Link to post
Share on other sites

#12 ·  Posted

If you have winrar installed you can run command line paramters through it and get the same effect. However each computer must have it installed. Check the WinRAR help file for more information.

Share this post


Link to post
Share on other sites

Yes we know, but we didn't ask for this. So far I use the command line unrar.exe. What we are looking for is to intergrate RAR's functionality in our scripts without the use/control of an external program. It is unlikely for someone to seek RAR's DLL functionality while being unaware of the unrar.exe...

Share this post


Link to post
Share on other sites

Use this...(see attached AutoIt file for usage)

// UnRarAutoitWrapper.cpp : Defines the entry point for the DLL application.
//

#define STRICT
#include "stdafx.h"
#include <windows.h>
#include <stdio.h>
#include <ctype.h>
#include "unrar.h"

enum { EXTRACT, TEST, PRINT };

extern "C" __declspec(dllexport) void ExtractArchive(char *ArcName,int Mode,char *Password);
extern "C" __declspec(dllexport) int ListArchive(char *ArcName);
void ShowComment(char *CmtBuf);
extern "C" __declspec(dllexport)void OutHelp(void);
void OutOpenArchiveError(int Error,char *ArcName);
void ShowArcInfo(unsigned int Flags,char *ArcName);
void OutProcessFileError(int Error);
int CALLBACK CallbackProc(UINT msg,LONG UserData,LONG P1,LONG P2);

BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
    return TRUE;
}

extern "C" __declspec(dllexport) void ExtractArchive(char *ArcName,int Mode,char *Password)
{
    HANDLE hArcData;
    int RHCode,PFCode;
    char CmtBuf[16384];
    struct RARHeaderData HeaderData;
    struct RAROpenArchiveDataEx OpenArchiveData;

    memset(&OpenArchiveData,0,sizeof(OpenArchiveData));
    OpenArchiveData.ArcName=ArcName;
    OpenArchiveData.CmtBuf=CmtBuf;
    OpenArchiveData.CmtBufSize=sizeof(CmtBuf);
    OpenArchiveData.OpenMode=RAR_OM_EXTRACT;
    hArcData=RAROpenArchiveEx(&OpenArchiveData);
    
    if(strlen(Password)) RARSetPassword(hArcData,Password);

  if (OpenArchiveData.OpenResult!=0)
  {
    OutOpenArchiveError(OpenArchiveData.OpenResult,ArcName);
    return;
  }

  ShowArcInfo(OpenArchiveData.Flags,ArcName);

  if (OpenArchiveData.CmtState==1)
    ShowComment(CmtBuf);

  RARSetCallback(hArcData,CallbackProc,(LONG)&Mode);

  HeaderData.CmtBuf=NULL;

  while ((RHCode=RARReadHeader(hArcData,&HeaderData))==0)
  {
    switch(Mode)
    {
      case EXTRACT:
        //printf("\nExtracting %-45s",HeaderData.FileName);
        break;
      case TEST:
        //printf("\nTesting %-45s",HeaderData.FileName);
        break;
      case PRINT:
        //printf("\nPrinting %-45s\n",HeaderData.FileName);
        break;
    }
    PFCode=RARProcessFile(hArcData,(Mode==EXTRACT) ? RAR_EXTRACT:RAR_TEST,
                          NULL,NULL);
    if (PFCode==0)
    {
        //printf(" Ok");
    }
    else
    {
      OutProcessFileError(PFCode);
      break;
    }
  }

  if (RHCode==ERAR_BAD_DATA)
    //printf("\nFile header broken");

  RARCloseArchive(hArcData);
}


extern "C" __declspec(dllexport) int ListArchive(char *ArcName)
{
  HANDLE hArcData;
  int RHCode,PFCode;
  char CmtBuf[16384];
  struct RARHeaderDataEx HeaderData;
  struct RAROpenArchiveDataEx OpenArchiveData;
    
  ////printf("Livewire\n");

  memset(&OpenArchiveData,0,sizeof(OpenArchiveData));
  OpenArchiveData.ArcName=ArcName;
  OpenArchiveData.CmtBuf=CmtBuf;
  OpenArchiveData.CmtBufSize=sizeof(CmtBuf);
  OpenArchiveData.OpenMode=RAR_OM_LIST;
  hArcData=RAROpenArchiveEx(&OpenArchiveData);

  if (OpenArchiveData.OpenResult!=0)
  {
    OutOpenArchiveError(OpenArchiveData.OpenResult,ArcName);
    return -1;
  }

  ShowArcInfo(OpenArchiveData.Flags,ArcName);

  if (OpenArchiveData.CmtState==1)
    ShowComment(CmtBuf);

  RARSetCallback(hArcData,CallbackProc,0);

  HeaderData.CmtBuf=CmtBuf;
  HeaderData.CmtBufSize=sizeof(CmtBuf);

  //printf("\nFile                     Size");
  //printf("\n-------------------------------");
  while ((RHCode=RARReadHeaderEx(hArcData,&HeaderData))==0)
  {
    __int64 UnpSize=HeaderData.UnpSize+(((__int64)HeaderData.UnpSizeHigh)<<32);
    //printf("\n%-20s %10Ld ",HeaderData.FileName,UnpSize);
    if (HeaderData.CmtState==1)
      ShowComment(CmtBuf);
    if ((PFCode=RARProcessFile(hArcData,RAR_SKIP,NULL,NULL))!=0)
    {
      OutProcessFileError(PFCode);
      break;
    }
  }

  if (RHCode==ERAR_BAD_DATA)
    //printf("\nFile header broken");

  RARCloseArchive(hArcData);
  return 1;
}


void ShowComment(char *CmtBuf)
{
    //MessageBoxA(NULL, _T(CmtBuf), _T("Comment:"), MB_OK);
    MessageBoxA(NULL, CmtBuf, "Comment:", MB_OK);
    ////printf("\nComment:\n%s\n",CmtBuf);
}


extern "C" __declspec(dllexport) void OutHelp(void)
{
    //MessageBox(NULL, _T("This is a message box test!"), _T("Text:"), MB_OK);

    //printf("\nUNRDLL.   This is a simple example of UNRAR.DLL usage\n");
    //printf("\nSyntax:\n");
    //printf("\nUNRDLL X <Archive>   extract archive contents");
    //printf("\nUNRDLL T <Archive>   test archive contents");
    //printf("\nUNRDLL P <Archive>   print archive contents to stdout");
    //printf("\nUNRDLL L <Archive>   view archive contents\n");
}


void OutOpenArchiveError(int Error,char *ArcName)
{
    switch(Error)
    {
        case ERAR_NO_MEMORY:
            MessageBoxA(NULL, "Not enough memory", ArcName, MB_OK);
            break;
        case ERAR_EOPEN:
            MessageBoxA(NULL, "Cannot open archive", ArcName, MB_OK);
            break;
        case ERAR_BAD_ARCHIVE:
            MessageBoxA(NULL, "Not RAR archive", ArcName, MB_OK);
            break;
        case ERAR_BAD_DATA:
            MessageBoxA(NULL, "Archive header broken", ArcName, MB_OK);
            break;
        case ERAR_UNKNOWN:
            MessageBoxA(NULL, "Unknown error", ArcName, MB_OK);
            break;
    }
}


void ShowArcInfo(unsigned int Flags,char *ArcName)
{
    //printf("\nArchive %s\n",ArcName);
    //printf("\nVolume:\t\t%s",(Flags & 1) ? "yes":"no");
    //printf("\nComment:\t%s",(Flags & 2) ? "yes":"no");
    //printf("\nLocked:\t\t%s",(Flags & 4) ? "yes":"no");
    //printf("\nSolid:\t\t%s",(Flags & 8) ? "yes":"no");
    //printf("\nNew naming:\t%s",(Flags & 16) ? "yes":"no");
    //printf("\nAuthenticity:\t%s",(Flags & 32) ? "yes":"no");
    //printf("\nRecovery:\t%s",(Flags & 64) ? "yes":"no");
    //printf("\nEncr.headers:\t%s",(Flags & 128) ? "yes":"no");
    //printf("\nFirst volume:\t%s",(Flags & 256) ? "yes":"no or older than 3.0");
    //printf("\n---------------------------\n");
}


void OutProcessFileError(int Error)
{
    switch(Error)
    {
        case ERAR_UNKNOWN_FORMAT:
            MessageBoxA(NULL, "Unknown archive format", "OutProcessFileError", MB_OK);
            break;
        case ERAR_BAD_ARCHIVE:
            MessageBoxA(NULL, "Bad volume", "OutProcessFileError", MB_OK);
            break;
        case ERAR_ECREATE:
            MessageBoxA(NULL, "File create error", "OutProcessFileError", MB_OK);
            break;
        case ERAR_EOPEN:
            MessageBoxA(NULL, "Volume open error", "OutProcessFileError", MB_OK);
            break;
        case ERAR_ECLOSE:
            MessageBoxA(NULL, "File close error", "OutProcessFileError", MB_OK);
            break;
        case ERAR_EREAD:
            MessageBoxA(NULL, "Read error", "OutProcessFileError", MB_OK);
            break;
        case ERAR_EWRITE:
            MessageBoxA(NULL, "Write error", "OutProcessFileError", MB_OK);
            break;
        case ERAR_BAD_DATA:
            MessageBoxA(NULL, "CRC error", "OutProcessFileError", MB_OK);
            break;
        case ERAR_UNKNOWN:
            MessageBoxA(NULL, "Unknown error", "OutProcessFileError", MB_OK);
            break;
    }
}

int CALLBACK CallbackProc(UINT msg,LONG UserData,LONG P1,LONG P2)
{
  switch(msg)
  {
    case UCM_CHANGEVOLUME:
      if (P2==RAR_VOL_ASK)
      {
        //printf("\n\nVolume %s is required\nPossible options:\n",(char *)P1);
        //printf("\nEnter - try again");
        //printf("\n'R'   - specify a new volume name");
        //printf("\n'Q'   - quit");
        //printf("\nEnter your choice: ");
        switch(toupper(getchar()))
        {
          case 'Q':
            return(-1);
          case 'R':
            {
              char *eol;
              //printf("\nEnter new name: ");
              fflush(stdin);
              fgets((char *)P1,MAX_PATH,stdin);
              eol=strpbrk((char *)P1,"\r\n");
              if (eol!=NULL)
                *eol=0;
            }
            return(0);
          default:
            return(0);
        }
      }
      if (P2==RAR_VOL_NOTIFY)
        //printf("\n  ... volume %s\n",(char *)P1);
      return(0);
    case UCM_PROCESSDATA:
      if (UserData!=0 && *(int *)UserData==PRINT)
      {
        fflush(stdout);
        fwrite((char *)P1,1,P2,stdout);
        fflush(stdout);
      }
      return(0);
    case UCM_NEEDPASSWORD:
      //printf("\nPassword required: ");
      gets((char *)P1);
      return(0);
  }
  return(0);
}

UnrarWithAutoIt.zip

Share this post


Link to post
Share on other sites

Hi use UnrarWithAutoIt and i have a poblem

I want extract a rar data with

DllCall("UnRarAutoitWrapper.dll","none","ExtractArchive","str",$filename,"int",0,"str","")

i have no error and i can extract the rar file!

But all my friends how want to extract the same rar file get error = 1 and the programm will close? why?!? o.O

Share this post


Link to post
Share on other sites

Do your friends have UnRarAutoitWrapper.dll on their computers? I'm guessing not.

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

yes they have.

thats an auto patcher he download the rar file and unrar it

Func _downloadgame($Gamefiles,$Sdata_opt,$hentai_opt,$SData,$Hentai)
    GUICtrlSetData($InfoLaleb, "Start Downloading")
    sleep(200)
    If $Gamefiles = 0 Then
    GUICtrlSetData($InfoLaleb, "Download Gamefiles")
    $Filea="http://www.minion-messenger.de/squadro-patch/SquadRo.rar"
    $size = InetGetSize($Filea)

    ProgressOn ( "Downloading GameFiles", "0% downloaded" , $size & " bytes remaining" )
    InetGet($Filea,"SquadRo.rar",1,1)

    While @InetGetActive
    $Percent=Int((@InetGetBytesRead*100)/$size)
    $Remain=$size-@InetGetBytesRead
    ProgressSet( $Percent,$Remain & " bytes remaining", $Percent & "% downloaded")
    Sleep(100)
    WEnd
    ProgressOff()
    GUICtrlSetData($InfoLaleb, "Download Gamefiles Complete. Wait!")

        Sleep(5000)
    if FileExists("SquadRo.rar") Then _unrar_file("SquadRo.rar")

Func _unrar_file($filename)
        GUICtrlSetData($InfoLaleb, "UnRar, wait please...")
    DllCall("UnRarAutoitWrapper.dll","none","ExtractArchive","str",$filename,"int",0,"str","")
    If @error Then MsgBox(0,"@error = " & @error,"Error calling ExtractArchive")
        Sleep(100)
        GUICtrlSetData($InfoLaleb, "UnRar done!")
EndFunc

all have the same files and dlls

Edited by ZeraKakkade

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

Try this dll...see AutoIt file for usage.

Note: Requires unrar.dll

// UnRarAutoitWrapper2005.cpp : Defines the entry point for the DLL application.
//

#define STRICT
#include "stdafx.h"
#include <windows.h>
#include <stdio.h>
#include <ctype.h>
#include "unrar.h"

void _stdcall ExtractArchive(char *ArcName,char *Password);

BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
    return TRUE;
}

void _stdcall ExtractArchive(char *ArcName,char *Password)
{
    HANDLE hArcData;
    int RHCode,PFCode;
    char CmtBuf[16384];
    struct RARHeaderData HeaderData;
    struct RAROpenArchiveDataEx OpenArchiveData;

    memset(&OpenArchiveData,0,sizeof(OpenArchiveData));
    OpenArchiveData.ArcName=ArcName;
    OpenArchiveData.CmtBuf=CmtBuf;
    OpenArchiveData.CmtBufSize=sizeof(CmtBuf);
    OpenArchiveData.OpenMode=RAR_OM_EXTRACT;
    hArcData=RAROpenArchiveEx(&OpenArchiveData);
    
    if(strlen(Password)) RARSetPassword(hArcData,Password);

  if (OpenArchiveData.OpenResult!=0)
  {
    return;
  }

  HeaderData.CmtBuf=NULL;

  while ((RHCode=RARReadHeader(hArcData,&HeaderData))==0)
  {
    PFCode=RARProcessFile(hArcData,RAR_EXTRACT,NULL,NULL);
    if (PFCode==0)
    {
        //printf(" Ok");
    }
    else
    {
      break;
    }
  }
  RARCloseArchive(hArcData);
}

UnRarAutoitWrapper.zip

Edited by livewire

Share this post


Link to post
Share on other sites

öm lol now all have a fatal error with this new dll xD

Posted Image

all files are at the same folder. you can see the files at this image

Share this post


Link to post
Share on other sites

Replace

DllCall("UnRarAutoItWrapper.dll","none","ExtractArchive","str",$filename,"int",0,"str","")

With

DllCall("UnRarAutoItWrapper.dll","none","ExtractArchive","str",$filename,"str","")

-Livewire

Share this post


Link to post
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
Sign in to follow this  
Followers 0