473,241 Members | 1,501 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,241 software developers and data experts.

UnRAROCX.ocx and unrar.dll

Hello all,

Has anyone managed to use the UnRAR OCX from www.rarlabs.com ?
Or even the unRAR.dll file using declares ?

If so, how ? :)

With the ocx I get in interop error message, with the dll I get a Null
exception on the "ReadRARHeader" function.

If anyone can help or wants to see the code just drop me a mail/message.
Hope someones had more luck than me !

Thanks
Ben S
---
Nov 20 '05 #1
8 6784
On 2004-02-01, Ben S <be*********@hotmail.com> wrote:
Hello all,

Has anyone managed to use the UnRAR OCX from www.rarlabs.com ?
Or even the unRAR.dll file using declares ?

If so, how ? :)

With the ocx I get in interop error message, with the dll I get a Null
exception on the "ReadRARHeader" function.

If anyone can help or wants to see the code just drop me a mail/message.
Hope someones had more luck than me !


I haven't used either - but the null reference exception is more then
likely because of improper declaration. Can you post your declaration
of the function and the original C/C++ prototype?

--
Tom Shelton [MVP]
Powered By Gentoo Linux 1.4
"I teleported home one night
With Ron and Sid and Meg.
Ron stole Meggie's heart away
And I got Sidney's leg."

- A poem about matter transference beams.
Nov 20 '05 #2
Hello Tom,

OK, these are the original Strutures and DLL declares.
(from the VB6 Expamle)

Private Type RARHeaderData
ArcName As String * 260
FileName As String * 260
Flags As Long
PackSize As Long
UnpSize As Long
HostOS As Long
FileCRC As Long
FileTime As Long
UnpVer As Long
Method As Long
FileAttr As Long
CmtBuf As String
CmtBufSize As Long
CmtSize As Long
CmtState As Long
End Type

Private Type RAROpenArchiveData
ArcName As String
OpenMode As Long
OpenResult As Long
CmtBuf As String
CmtBufSize As Long
CmtSize As Long
CmtState As Long
End Type

Private Declare Function RAROpenArchive Lib "unrar.dll" (ByRef ArchiveData
As RAROpenArchiveData) As Long
Private Declare Function RARCloseArchive Lib "unrar.dll" (ByVal hArcData As
Long) As Long
Private Declare Function RARReadHeader Lib "unrar.dll" (ByVal hArcData As
Long, ByRef HeaderData As RARHeaderData) As Long
Private Declare Function RARProcessFile Lib "unrar.dll" (ByVal hArcData As
Long, ByVal Operation As Long, ByVal DestPath As String, ByVal DestName As
String) As Long
Private Declare Sub RARSetChangeVolProc Lib "unrar.dll" (ByVal hArcData As
Long, ByVal Mode As Long)
Private Declare Sub RARSetPassword Lib "unrar.dll" (ByVal hArcData As Long,
ByVal Password As String)

-------------------------------New------------------
These are the structures and DLL calls I used after changing them:

Private Type RARHeaderData
ArcName As String
FileName As String
Flags As Integer
PackSize As Integer
UnpSize As Integer
HostOS As Integer
FileCRC As Integer
FileTime As Integer
UnpVer As Integer
Method As Integer
FileAttr As Integer
CmtBuf As String
CmtBufSize As Integer
CmtSize As Integer
CmtState As Integer
End Type

Private Type RAROpenArchiveData
ArcName As String
OpenMode As Integer
OpenResult As Integer
CmtBuf As String
CmtBufSize As Integer
CmtSize As Integer
CmtState As Integer
End Type

Private Declare Function RAROpenArchive Lib "unrar.dll" (ByRef ArchiveData
As RAROpenArchiveData) As Integer
Private Declare Function RARCloseArchive Lib "unrar.dll" (ByVal hArcData As
Integer) As Integer
Private Declare Function RARReadHeader Lib "unrar.dll" (ByVal hArcData As
Integer, ByRef HeaderData As RARHeaderData) As Integer
Private Declare Function RARProcessFile Lib "unrar.dll" (ByVal hArcData As
Integer, ByVal Operation As Integer, ByVal DestPath As String, ByVal
DestName As String) As Integer
Private Declare Sub RARSetChangeVolProc Lib "unrar.dll" (ByVal hArcData As
Integer, ByVal Mode As Integer)
Private Declare Sub RARSetPassword Lib "unrar.dll" (ByVal hArcData As
Integer, ByVal Password As String)
I've also tried making the strings like this in the structure this:
<MarshalAs(UnmanagedType.LPTStr, SizeConst:=260)>Dim ArcName as String

And the same for FileName and CmtBuf but it still brings up the same error

"An unhandled exception of type 'System.NullReferenceException; occured in
RarOCXTest.exe

Additional information: Object reference not set to an instance of an
object."

Hope that's of some use. It all seems to be OK to me, but I can't spot
where I'm going wrong

Thanks
Ben S
---
I haven't used either - but the null reference exception is more then
likely because of improper declaration. Can you post your declaration
of the function and the original C/C++ prototype?

--
Tom Shelton [MVP]
Powered By Gentoo Linux 1.4
"I teleported home one night
With Ron and Sid and Meg.
Ron stole Meggie's heart away
And I got Sidney's leg."

- A poem about matter transference beams.

Nov 20 '05 #3
In article <nY***********@news-binary.blueyonder.co.uk>, Ben S wrote:
Hello Tom,

OK, these are the original Strutures and DLL declares.
(from the VB6 Expamle)


<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi)> _
Private Structure RARHeaderData

<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=260)> _
Public ArcName As String

<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=260)> _
Public FileName As String

Public Flags As Integer
Public PackSize As Integer
Public UnpSize As Integer
Public HostOS As Integer
Public FileCRC As Integer
Public FileTime As Integer
Public UnpVer As Integer
Public Method As Integer
Public FileAttr As Integer
Public CmtBuf As String
Public CmtBufSize As Integer
Public CmtSize As Integer
Public CmtState As Integer
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi)>_
Private Structure RAROpenArchiveData
Public ArcName As String
Public OpenMode As Integer
Public OpenResult As Integer
Public CmtBuf As String
CmtBufSize As Integer
Public CmtSize As Integer
Public CmtState As Integer
End Structure

Private Declare Ansi Function RAROpenArchive Lib "unrar.dll" _
(ByRef ArchiveData As RAROpenArchiveData) As Integer

' using integer, but probably should by System.IntPtr
Private Declare Function RARCloseArchive Lib "unrar.dll" _
(ByVal hArcData As Integer) As Integer

Private Declare Ansi Function RARReadHeader Lib "unrar.dll" _
(ByVal hArcData As Integer, _
ByRef HeaderData As RARHeaderData) As Integer

Private Declare Ansi Function RARProcessFile Lib "unrar.dll" _
(ByVal hArcData As Integer, _
ByVal Operation As Integer, _
ByVal DestPath As String, _
ByVal DestName As String) As Integer

Private Declare Sub RARSetChangeVolProc Lib "unrar.dll" _
(ByVal hArcData As Integer, _
ByVal Mode As Integer)

Private Declare Ansi Sub RARSetPassword Lib "unrar.dll" _
(ByVal hArcData As Integer, ByVal Password As String)
With out looking at the docs, this is what I would do...

--
Tom Shelton [MVP]
OS Name: Microsoft Windows XP Professional
OS Version: 5.1.2600 Service Pack 1 Build 2600
System Up Time: 5 Days, 0 Hours, 8 Minutes, 46 Seconds
Nov 20 '05 #4
Hello there,
With out looking at the docs, this is what I would do...
Without looking at the docs, you've solved my problem ! I never did like
APIs ;)
If there's a place to vote you for to keep the MVP send me the link !!

Thanks Tom, your help is appreciated greatly, you're one of the people that
make the Internet a good place to be.

Right I'm off to introduce this to a couple of apps with "Under Development"
routines in them.

Thanks once again
Ben S
---

"Tom Shelton" <to*@mtogden.com> wrote in message
news:eg**************@TK2MSFTNGP12.phx.gbl... In article <nY***********@news-binary.blueyonder.co.uk>, Ben S wrote:
Hello Tom,

OK, these are the original Strutures and DLL declares.
(from the VB6 Expamle)


<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi)> _
Private Structure RARHeaderData

<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=260)> _
Public ArcName As String

<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=260)> _
Public FileName As String

Public Flags As Integer
Public PackSize As Integer
Public UnpSize As Integer
Public HostOS As Integer
Public FileCRC As Integer
Public FileTime As Integer
Public UnpVer As Integer
Public Method As Integer
Public FileAttr As Integer
Public CmtBuf As String
Public CmtBufSize As Integer
Public CmtSize As Integer
Public CmtState As Integer
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi)>_
Private Structure RAROpenArchiveData
Public ArcName As String
Public OpenMode As Integer
Public OpenResult As Integer
Public CmtBuf As String
CmtBufSize As Integer
Public CmtSize As Integer
Public CmtState As Integer
End Structure

Private Declare Ansi Function RAROpenArchive Lib "unrar.dll" _
(ByRef ArchiveData As RAROpenArchiveData) As Integer

' using integer, but probably should by System.IntPtr
Private Declare Function RARCloseArchive Lib "unrar.dll" _
(ByVal hArcData As Integer) As Integer

Private Declare Ansi Function RARReadHeader Lib "unrar.dll" _
(ByVal hArcData As Integer, _
ByRef HeaderData As RARHeaderData) As Integer

Private Declare Ansi Function RARProcessFile Lib "unrar.dll" _
(ByVal hArcData As Integer, _
ByVal Operation As Integer, _
ByVal DestPath As String, _
ByVal DestName As String) As Integer

Private Declare Sub RARSetChangeVolProc Lib "unrar.dll" _
(ByVal hArcData As Integer, _
ByVal Mode As Integer)

Private Declare Ansi Sub RARSetPassword Lib "unrar.dll" _
(ByVal hArcData As Integer, ByVal Password As String)

--
Tom Shelton [MVP]
OS Name: Microsoft Windows XP Professional
OS Version: 5.1.2600 Service Pack 1 Build 2600
System Up Time: 5 Days, 0 Hours, 8 Minutes, 46 Seconds

Nov 20 '05 #5
In article <lu***************@news-binary.blueyonder.co.uk>, Ben S wrote:
Hello there,
With out looking at the docs, this is what I would do...


Without looking at the docs, you've solved my problem ! I never did like
APIs ;)


I'm glad it worked for you :) Good luck.

--
Tom Shelton [MVP]
OS Name: Microsoft Windows XP Professional
OS Version: 5.1.2600 Service Pack 1 Build 2600
System Up Time: 5 Days, 2 Hours, 8 Minutes, 50 Seconds
Nov 20 '05 #6
> I'm glad it worked for you :) Good luck.

The listing works fine. The extraction, that's something else.
It seems to be ignoring the string that I'm giving it as a destination and
defaulting in the current folder.

I've now got what you suggested and for listing this works a treat, when I
pass any sort of sting as the DestPath it seems to be ignored.
How do I feed it a string in the correct format (I'm guessing something to
do with the ANSI setup of the DLL declare).
I've tried with and without a trailing \ on the path, with and without a
vbNull on the end
Also tried setting up a basic structure like the others with the string as
the only item, then passing that but it didn't want to work and dropped the
files in the same place as before.

Private Declare Ansi Function RARProcessFile Lib "unrar.dll" _
(ByVal hArcData As Integer, _
ByVal Operation As Integer, _
ByVal DestPath As String, _
ByVal DestName As String) As Integer

Sorry to keep picking your brains.

Thanks in advance
Ben S
---

--
Tom Shelton [MVP]
OS Name: Microsoft Windows XP Professional
OS Version: 5.1.2600 Service Pack 1 Build 2600
System Up Time: 5 Days, 2 Hours, 8 Minutes, 50 Seconds

Nov 20 '05 #7
In article <RG*************@news-binary.blueyonder.co.uk>, Ben S wrote:
I'm glad it worked for you :) Good luck.


The listing works fine. The extraction, that's something else.
It seems to be ignoring the string that I'm giving it as a destination and
defaulting in the current folder.

I've now got what you suggested and for listing this works a treat, when I
pass any sort of sting as the DestPath it seems to be ignored.
How do I feed it a string in the correct format (I'm guessing something to
do with the ANSI setup of the DLL declare).
I've tried with and without a trailing \ on the path, with and without a
vbNull on the end
Also tried setting up a basic structure like the others with the string as
the only item, then passing that but it didn't want to work and dropped the
files in the same place as before.

Private Declare Ansi Function RARProcessFile Lib "unrar.dll" _
(ByVal hArcData As Integer, _
ByVal Operation As Integer, _
ByVal DestPath As String, _
ByVal DestName As String) As Integer

Sorry to keep picking your brains.


No problem... I'm a little stumped. I just downloaded and installed
the unrar.dll stuff, and this should work - though I haven't actually
tried it out. Can you post the actuall code were it's failing?
I would like to see what arguments your passing and also I would like
to know what the return value of RARProcessFile is...

--
Tom Shelton [MVP]
OS Name: Microsoft Windows XP Professional
OS Version: 5.1.2600 Service Pack 1 Build 2600
System Up Time: 0 Days, 22 Hours, 39 Minutes, 42 Seconds
Nov 20 '05 #8
> No problem... I'm a little stumped.

Kinda glad it's not just being a little dense !
I just downloaded and installed the unrar.dll stuff, and this should work - though I haven't actually tried it out. Can you post the actuall code were it's failing?


----Code----
..
Case RarOperations.OP_EXTRACT
txtOut.text += "Extracting " & sStat
Ret = RARProcessFile(lHandle, RAR_EXTRACT, "D:\TestFolder\Dump",
uHeader.FileName.ToString)
Case RarOperations.OP_TEST
..
----Code----

The Ret value is 0 when I look at it showing success, which is true, but
it's ignored the DestFolder pram.
Looking though the DLL documentation I've found one error with the code,
I've specified the filename which overrides the DestPath and uses the
current folder.
After changing this I've now got it to the stage where it looks like

Ret = RARProcessFile(lHandle, RAR_EXTRACT, "D:\TestFolder\Dump", vbNull)

Which gives an error.
<time passes>
And playing with it as I typed this gave me

Ret = RARProcessFile(lHandle, RAR_EXTRACT, "D:\TestFolder\Dump", "")

which worked !!
This creates the folder in the "D:\TestFolder\Dump" folder and then extracts
all the files to it!
It's so much easier to work when you can bounce ideas of someone!!

Once again, thanks for you time, this has been a good learning experience
for me.
My mind is wandering to a .Net Component for UnRARing now..... The phrase
"Learn to walk before you run" springs to mind.
If you're ever Kent way I'll buy you a drink ;)

Thanks
Ben S
---
Nov 20 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Brian Mitchell | last post by:
How do I prevent other people from using the dll's I create? I looked at identity permissions but it looks like those are more for identifying an assembly. Any help would be great. Thanks!!
0
by: Shadowboxer | last post by:
has anybody come across an UnRAR Library for VS.NET? I can't find anything useful and the latest examples on eugene's site are vb6 and they won't compile properly in .net thanks -J
3
by: Oliver | last post by:
Hello! I am really stuck... I have searched the whole internet to find a dll or a API which I can use in .NET C# to uncompress all the major archiv files but I really didnt find anything whith...
4
by: Oliver | last post by:
Hello ! I am trying to get the unrar.dll working in C#... it seems that I correctly imported the functions as the first 2 function work without problem (RAROpenArchive & RARGetDLLVersion)......
2
by: mmmobasher | last post by:
Dear sirs after some googling i found some code to using unrar.dll, but i get runtime error System.NullReferenceException in line iStatus=RARReadHeader(lHandle, ref uHeader); hear is the code ...
2
by: mmmobasher | last post by:
finaly this code seems to work but it doesn't extract anything and flags returns success, any oponion? using System; using System.Runtime.InteropServices; namespace Unrar { /// <summary>
0
by: Ben S | last post by:
Hello all, Has anyone managed to use the UnRAR OCX from www.rarlabs.com ? Or even the unRAR.dll file using declares ? If so, how ? :) With the ocx I get in interop error message, with the...
0
by: federico | last post by:
Hello, how can I make a program respond to another program's input request? For example, this code: Process.Start("unrar.exe", "e D:\temp\key.rar D:temp2") SendKeys.SendWait("test~") will...
1
by: Christian Reizlein | last post by:
Does anyone has a class that allow to manage RAR files in VB.net in a native way? not using ActiveX controls or DLLs ?
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.