473,466 Members | 1,395 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 6813
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 ?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.