Page 1 of 2
WinRar Free UnPack DLL and EXE
Posted: Thu Feb 19, 2009 9:37 pm
by codeman
Hello,
i have found a DLL and an Exe on this Site:
http://www.rarlab.com/rar_add.htm. With this tool you can unpack Rar files... I find this very interesting. Of course they haven't a PureBasic example for the DLL. But they have examples for C, C#, Delphi, Free Pascal, MASM, VB.NET, Virtual Pascal and VBasic! Can anybody translate one of this code to PureBasic!
DOWNLOAD Dll + Sourcescode
And I have found an EXE who unpack automatic but they haven't a list with the commands

!
yours, codeman
Posted: Thu Feb 19, 2009 9:48 pm
by ts-soft
Posted: Thu Feb 19, 2009 9:54 pm
by codeman
Thank you!
Posted: Sat Feb 28, 2009 11:05 pm
by codeman
Sorry but this Example doesen't work. Or I use the wrong unrar.dll.
Know anybody an other example to unpack rar archives?
Yours codeman
Posted: Sat Feb 28, 2009 11:38 pm
by atomo
Hi, try this as an include pbi file.
Code: Select all
;PB_unRAR - Paul Leischow, Sept.6, 2002
;RAR Archive extractor that uses the free UNRAR.DLL
#ERAR_END_ARCHIVE = 10
#ERAR_NO_MEMORY = 11
#ERAR_BAD_DATA = 12
#ERAR_BAD_ARCHIVE = 13
#ERAR_UNKNOWN_FORMAT = 14
#ERAR_EOPEN = 15
#ERAR_ECREATE = 16
#ERAR_ECLOSE = 17
#ERAR_EREAD = 18
#ERAR_EWRITE = 19
#ERAR_SMALL_BUF = 20
#ERAR_UNKNOWN = 21
#ERAR_MISSING_PASSWORD = 22
#RAR_HEADERFLAG_ENCRYPTED = %00000100
#RAR_OM_LIST = 0
#RAR_OM_EXTRACT = 1
#RAR_OM_LIST_INCSPLIT = 2
#RAR_SKIP = 0
#RAR_TEST = 1
#RAR_EXTRACT = 2
#RAR_VOL_ASK = 0
#RAR_VOL_NOTIFY = 1
#RAR_DLL_VERSION = 4
Structure RARHeaderData
ArcName.b[260]
FileName.b[260]
Flags.l
PackSize.l
UnpSize.l
HostOS.l
FileCRC.l
FileTime.l
UnpVer.l
Method.l
FileAttr.l
*CmtBuf.l
CmtBufSize.l
CmtSize.l
CmtState.l
EndStructure
Structure RARHeaderDataEx
ArcName.b[1024]
ArcNameW.w[1024]
FileName.b[1024]
FileNameW.w[1024]
Flags.l
PackSize.l
PackSizeHigh.l
UnpSize.l
UnpSizeHigh.l
HostOS.l
FileCRC.l
FileTime.l
UnpVer.l
Method.l
FileAttr.l
*CmtBuf.l
CmtBufSize.l
CmtSize.l
CmtState.l
Reserved.l[1024]
EndStructure
Structure RAROpenArchiveData
*ArcName.l
OpenMode.l
OpenResult.l
*CmtBuf.l
CmtBufSize.l
CmtSize.l
CmtState.l
EndStructure
Structure RAROpenArchiveDataEx
*ArcName.l
*ArcNameW.l
OpenMode.l
OpenResult.l
*CmtBuf.l
CmtBufSize.l
CmtSize.l
CmtState.l
Flags.l
Reserved.l[32]
EndStructure
Global RarLib.l
Global RAROpenArchive.l
Global RARCloseArchive.l
Global RARReadHeader.l
Global RARProcessFile.l
Global RARSetCallback.l
Global RARSetChangeVolProc.l
Global RARSetProcessDataProc.l
Global RARSetPassword.l
Global RARGetDllVersion.l
Prototype.l Prot_RAROpenArchive(a.l)
Prototype.l Prot_RARCloseArchive(a.l)
Prototype.l Prot_RARReadHeader(a.l,b.l)
CompilerIf #PB_Compiler_Unicode=0
Prototype.l Prot_RARProcessFile(a.l,b.l,c.p-ascii,d.p-ascii)
CompilerElse
Prototype.l Prot_RARProcessFile(a.l,b.l,c.p-unicode,d.p-unicode)
CompilerEndIf
Prototype.l Prot_RARSetCallback(a.l,b.l,c.l)
Prototype.l Prot_RARSetChangeVolProc(a.l,b.l)
Prototype.l Prot_RARSetProcessDataProc(a.l,b.l)
CompilerIf #PB_Compiler_Unicode=0
Prototype.l Prot_RARSetPassword(a.l,b.p-ascii)
CompilerElse
Prototype.l Prot_RARSetPassword(a.l,b.p-unicode)
CompilerEndIf
Prototype.l Prot_RARGetDllVersion()
ProcedureDLL Rar_Init()
RarLib=OpenLibrary(#PB_Any,"unrar.dll")
If RarLib
CompilerIf #PB_Compiler_Unicode=0
RAROpenArchive.Prot_RAROpenArchive = GetFunction(RarLib, "RAROpenArchive")
RARReadHeader.Prot_RARReadHeader = GetFunction(RarLib, "RARReadHeader")
RARProcessFile.Prot_RARProcessFile = GetFunction(RarLib, "RARProcessFile")
CompilerElse
RAROpenArchive.Prot_RAROpenArchive = GetFunction(RarLib, "RAROpenArchiveEx")
RARReadHeader.Prot_RARReadHeader = GetFunction(RarLib, "RARReadHeaderEx")
RARProcessFile.Prot_RARProcessFile = GetFunction(RarLib, "RARProcessFileW")
CompilerEndIf
RARCloseArchive.Prot_RARCloseArchive = GetFunction(RarLib, "RARCloseArchive")
RARSetCallback.Prot_RARSetCallback = GetFunction(RarLib, "RARSetCallback")
RARSetChangeVolProc.Prot_RARSetChangeVolProc = GetFunction(RarLib, "RARSetChangeVolProc")
RARSetProcessDataProc.Prot_RARSetProcessDataProc = GetFunction(RarLib, "RARSetProcessDataProc")
RARSetPassword.Prot_RARSetPassword = GetFunction(RarLib, "RARSetPassword")
RARGetDllVersion.Prot_RARGetDllVersion = GetFunction(RarLib, "RARGetDllVersion")
Else
MessageRequester("Erreur", "unrar.dll est introuvable.", #MB_ICONERROR)
End
EndIf
EndProcedure
ProcedureDLL Rar_End()
If RarLib
CloseLibrary(RarLib)
RarLib=0
EndIf
EndProcedure
Procedure UnRar(File$)
CompilerIf #PB_Compiler_Unicode=0
rarheader.RARHeaderData
raropen.RAROpenArchiveData
raropen\ArcName= @File$
CompilerElse
rarheader.RARHeaderDataEx
raropen.RAROpenArchiveDataEx
raropen\ArcNameW = @File$
CompilerEndIf
raropen\CmtBuf = 0
raropen\CmtBufSize = 0
raropen\OpenMode=#RAR_OM_EXTRACT
hRAR=RAROpenArchive(@raropen)
file.s=""
filelist.s=""
If raropen\OpenResult
MessageRequester("Error","Could Not Open RAR File",#MB_ICONERROR)
ProcedureReturn
EndIf
While RARReadHeader(hRAR,@rarheader)=0
CompilerIf #PB_Compiler_Unicode=0
file=PeekS(@rarheader\FileName)
CompilerElse
file=PeekS(@rarheader\FileNameW)
CompilerEndIf
Debug "File:"+file
filelist+file+Chr(10)
If rarheader\flags & #RAR_HEADERFLAG_ENCRYPTED
;Debug "#RAR_HEADERFLAG_ENCRYPTED"
RARSetPassword(hRAR,"free")
;MessageRequester("Error","file is password protected",#MB_ICONERROR)
EndIf
res=RARProcessFile(hRAR,#RAR_EXTRACT,"",File$)
Select res
Case #ERAR_BAD_DATA
Debug "File CRC error"
Case #ERAR_BAD_ARCHIVE
Debug "Volume is not valid RAR archive"
Case #ERAR_UNKNOWN_FORMAT
Debug "Unknown archive format"
Case #ERAR_EOPEN
Debug "Volume open error"
Case #ERAR_ECREATE
Debug "File create error"
Case #ERAR_ECLOSE
Debug "File close error"
Case #ERAR_EREAD
Debug "Read error"
Case #ERAR_EWRITE
Debug "Write error"
EndSelect
Wend
If RARCloseArchive(hRAR)=#ERAR_ECLOSE
MessageRequester("RARCloseArchive","Archive close error",#MB_ICONINFORMATION)
EndIf
EndProcedure
Rar_Init()
Posted: Sun Mar 01, 2009 9:43 am
by codeman
Sorry but I doesen't understand how I must use this?
Posted: Sun Mar 01, 2009 10:36 am
by atomo
The main file :
Code: Select all
XIncludeFile "Rar.pbi"
File.s = OpenFileRequester("Select Rar file", "C:\", "Rar (*.rar)|*.rar", 0)
If File
unrar(File)
EndIf
and the include :
Code: Select all
;PB_unRAR - Paul Leischow, Sept.6, 2002
;RAR Archive extractor that uses the free UNRAR.DLL
#ERAR_END_ARCHIVE = 10
#ERAR_NO_MEMORY = 11
#ERAR_BAD_DATA = 12
#ERAR_BAD_ARCHIVE = 13
#ERAR_UNKNOWN_FORMAT = 14
#ERAR_EOPEN = 15
#ERAR_ECREATE = 16
#ERAR_ECLOSE = 17
#ERAR_EREAD = 18
#ERAR_EWRITE = 19
#ERAR_SMALL_BUF = 20
#ERAR_UNKNOWN = 21
#ERAR_MISSING_PASSWORD = 22
#RAR_HEADERFLAG_ENCRYPTED = %00000100
#RAR_OM_LIST = 0
#RAR_OM_EXTRACT = 1
#RAR_OM_LIST_INCSPLIT = 2
#RAR_SKIP = 0
#RAR_TEST = 1
#RAR_EXTRACT = 2
#RAR_VOL_ASK = 0
#RAR_VOL_NOTIFY = 1
#RAR_DLL_VERSION = 4
Structure RARHeaderData
ArcName.b[260]
FileName.b[260]
Flags.l
PackSize.l
UnpSize.l
HostOS.l
FileCRC.l
FileTime.l
UnpVer.l
Method.l
FileAttr.l
*CmtBuf.l
CmtBufSize.l
CmtSize.l
CmtState.l
EndStructure
Structure RARHeaderDataEx
ArcName.b[1024]
ArcNameW.w[1024]
FileName.b[1024]
FileNameW.w[1024]
Flags.l
PackSize.l
PackSizeHigh.l
UnpSize.l
UnpSizeHigh.l
HostOS.l
FileCRC.l
FileTime.l
UnpVer.l
Method.l
FileAttr.l
*CmtBuf.l
CmtBufSize.l
CmtSize.l
CmtState.l
Reserved.l[1024]
EndStructure
Structure RAROpenArchiveData
*ArcName.l
OpenMode.l
OpenResult.l
*CmtBuf.l
CmtBufSize.l
CmtSize.l
CmtState.l
EndStructure
Structure RAROpenArchiveDataEx
*ArcName.l
*ArcNameW.l
OpenMode.l
OpenResult.l
*CmtBuf.l
CmtBufSize.l
CmtSize.l
CmtState.l
Flags.l
Reserved.l[32]
EndStructure
Global RarLib.l
Global RAROpenArchive.l
Global RARCloseArchive.l
Global RARReadHeader.l
Global RARProcessFile.l
Global RARSetCallback.l
Global RARSetChangeVolProc.l
Global RARSetProcessDataProc.l
Global RARSetPassword.l
Global RARGetDllVersion.l
Prototype.l Prot_RAROpenArchive(a.l)
Prototype.l Prot_RARCloseArchive(a.l)
Prototype.l Prot_RARReadHeader(a.l,b.l)
CompilerIf #PB_Compiler_Unicode=0
Prototype.l Prot_RARProcessFile(a.l,b.l,c.p-ascii,d.p-ascii)
CompilerElse
Prototype.l Prot_RARProcessFile(a.l,b.l,c.p-unicode,d.p-unicode)
CompilerEndIf
Prototype.l Prot_RARSetCallback(a.l,b.l,c.l)
Prototype.l Prot_RARSetChangeVolProc(a.l,b.l)
Prototype.l Prot_RARSetProcessDataProc(a.l,b.l)
CompilerIf #PB_Compiler_Unicode=0
Prototype.l Prot_RARSetPassword(a.l,b.p-ascii)
CompilerElse
Prototype.l Prot_RARSetPassword(a.l,b.p-unicode)
CompilerEndIf
Prototype.l Prot_RARGetDllVersion()
ProcedureDLL Rar_Init()
RarLib=OpenLibrary(#PB_Any,"unrar.dll")
If RarLib
CompilerIf #PB_Compiler_Unicode=0
RAROpenArchive.Prot_RAROpenArchive = GetFunction(RarLib, "RAROpenArchive")
RARReadHeader.Prot_RARReadHeader = GetFunction(RarLib, "RARReadHeader")
RARProcessFile.Prot_RARProcessFile = GetFunction(RarLib, "RARProcessFile")
CompilerElse
RAROpenArchive.Prot_RAROpenArchive = GetFunction(RarLib, "RAROpenArchiveEx")
RARReadHeader.Prot_RARReadHeader = GetFunction(RarLib, "RARReadHeaderEx")
RARProcessFile.Prot_RARProcessFile = GetFunction(RarLib, "RARProcessFileW")
CompilerEndIf
RARCloseArchive.Prot_RARCloseArchive = GetFunction(RarLib, "RARCloseArchive")
RARSetCallback.Prot_RARSetCallback = GetFunction(RarLib, "RARSetCallback")
RARSetChangeVolProc.Prot_RARSetChangeVolProc = GetFunction(RarLib, "RARSetChangeVolProc")
RARSetProcessDataProc.Prot_RARSetProcessDataProc = GetFunction(RarLib, "RARSetProcessDataProc")
RARSetPassword.Prot_RARSetPassword = GetFunction(RarLib, "RARSetPassword")
RARGetDllVersion.Prot_RARGetDllVersion = GetFunction(RarLib, "RARGetDllVersion")
Else
MessageRequester("Erreur", "unrar.dll est introuvable.", #MB_ICONERROR)
End
EndIf
EndProcedure
ProcedureDLL Rar_End()
If RarLib
CloseLibrary(RarLib)
RarLib=0
EndIf
EndProcedure
Procedure UnRar(File$)
CompilerIf #PB_Compiler_Unicode=0
rarheader.RARHeaderData
raropen.RAROpenArchiveData
raropen\ArcName= @File$
CompilerElse
rarheader.RARHeaderDataEx
raropen.RAROpenArchiveDataEx
raropen\ArcNameW = @File$
CompilerEndIf
raropen\CmtBuf = 0
raropen\CmtBufSize = 0
raropen\OpenMode=#RAR_OM_EXTRACT
hRAR=RAROpenArchive(@raropen)
file.s=""
filelist.s=""
If raropen\OpenResult
MessageRequester("Error","Could Not Open RAR File",#MB_ICONERROR)
ProcedureReturn
EndIf
While RARReadHeader(hRAR,@rarheader)=0
CompilerIf #PB_Compiler_Unicode=0
file=PeekS(@rarheader\FileName)
CompilerElse
file=PeekS(@rarheader\FileNameW)
CompilerEndIf
Debug "File:"+file
filelist+file+Chr(10)
If rarheader\flags & #RAR_HEADERFLAG_ENCRYPTED
;Debug "#RAR_HEADERFLAG_ENCRYPTED"
RARSetPassword(hRAR,"free")
;MessageRequester("Error","file is password protected",#MB_ICONERROR)
EndIf
res=RARProcessFile(hRAR,#RAR_EXTRACT,"",file)
Select res
Case #ERAR_BAD_DATA
Debug "File CRC error"
Case #ERAR_BAD_ARCHIVE
Debug "Volume is not valid RAR archive"
Case #ERAR_UNKNOWN_FORMAT
Debug "Unknown archive format"
Case #ERAR_EOPEN
Debug "Volume open error"
Case #ERAR_ECREATE
Debug "File create error"
Case #ERAR_ECLOSE
Debug "File close error"
Case #ERAR_EREAD
Debug "Read error"
Case #ERAR_EWRITE
Debug "Write error"
EndSelect
Wend
If RARCloseArchive(hRAR)=#ERAR_ECLOSE
MessageRequester("RARCloseArchive","Archive close error",#MB_ICONINFORMATION)
EndIf
EndProcedure
Rar_Init()
It should work but you must have the unrar.dll.
Posted: Sun Mar 01, 2009 9:06 pm
by codeman
Thank you!

Posted: Mon Mar 02, 2009 9:10 am
by User_Russian
Posted: Mon Mar 02, 2009 3:55 pm
by codeman
Thank you! The Lib Commads are good but the language... Have anybody a englisch or german Help?
Yours codeman
Posted: Mon Mar 02, 2009 6:03 pm
by codeman
In the Forum is the langue Russian! I have translate this but in the help stand things like this:
Ðàñïàêîâêà èëè òåñòèðîâàíèå àðõèâà
H_RAR - èäåíòèôèêàòîð àðõèâà, ïîëó÷åíûé ñ ïîìîùüþ RAR_OpenArchive
Operation - ×òî äåëàòü ñ ôàéëîì.
#RAR_SKIP - Ïðîïóñòèòü ôàéë ïðè ðàñïàêîâêå
#RAR_TEST - Òåñòèðîâàíèå
#RAR_EXTRACT - Ðàñïàêîâàòü
DestPath - ????
DestName - Èìÿ ôàéëà è ïóòü êóäà ðàñïàêîâàòü ôàéë
 êà÷åñòâå ðåçóëüòàòà ìîæåò áûòü -1 åñëè ïðîèçîøëè ïðîáëåìû ïðè èíèöèàëèçàöèè áèáëèîòåêè èëè ñëåäóþùåå ñîîáùåíèå
#RAR_BAD_DATA - Îøèáêà â CRC
#RAR_BAD_ARCHIVE - Ïîâðåæä¸ííûé èëè íåïîääåðæèâàåìûé ôîðìàò àðõèâà
#RAR_UNKNOWN_FORMAT - Íåèçâåñòíûé ôîðìàò àðõèâà. Âîçìîæíî ôàéë íå ÿâëÿåòñÿ àðõèâîì
#RAR_EOPEN - Ïðîèçîøëà îøèáêà ïðè èçâëå÷åíèè ôàéëà
#RAR_ECREATE - Íå óäàëîñü ñîçäàòü ôàéë
#RAR_ECLOSE - Îøèáêà ïðè çàêðûòèè ôàéëà
#RAR_EREAD - Îøèáêà ÷òåíèÿ
#ERAR_EWRITE - Îøèáêà çàïèñè
I think my help isn't compatible with Russian!
Can anybody help me?
Posted: Wed Mar 04, 2009 10:41 am
by User_Russian
Well, translate help
Posted: Wed Mar 04, 2009 1:45 pm
by User_Russian
Posted: Thu Mar 05, 2009 2:41 pm
by codeman
Thank you very much!
This is perfect!
Yours codeman
Posted: Thu Mar 05, 2009 4:23 pm
by codeman
Sorry but by the command: RAR_SetCallback(H_RAR, *CallbackProc, UserData) the help doesen't say anything! Can anybody give me an example for a callback in a ProgressBar?
Yours codeman