473,574 Members | 2,556 Online
Bytes | Software Development & Data Engineering Community
+ 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 "ReadRARHea der" 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 6826
On 2004-02-01, Ben S <be*********@ho tmail.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 "ReadRARHea der" 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 RAROpenArchiveD ata
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 RAROpenArchiveD ata) 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 RARSetChangeVol Proc 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 RAROpenArchiveD ata
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 RAROpenArchiveD ata) 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 RARSetChangeVol Proc 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(Unma nagedType.LPTSt r, 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.NullRef erenceException ; 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.blueyond er.co.uk>, Ben S wrote:
Hello Tom,

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


<StructLayout(L ayoutKind.Seque ntial, CharSet:=CharSe t.Ansi)> _
Private Structure RARHeaderData

<MarshalAs(Unma nagedType.ByVal TStr, SizeConst:=260) > _
Public ArcName As String

<MarshalAs(Unma nagedType.ByVal TStr, 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(L ayoutKind.Seque ntial, CharSet:=CharSe t.Ansi)>_
Private Structure RAROpenArchiveD ata
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 RAROpenArchiveD ata) 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 RARSetChangeVol Proc 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.co m> wrote in message
news:eg******** ******@TK2MSFTN GP12.phx.gbl... In article <nY***********@ news-binary.blueyond er.co.uk>, Ben S wrote:
Hello Tom,

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


<StructLayout(L ayoutKind.Seque ntial, CharSet:=CharSe t.Ansi)> _
Private Structure RARHeaderData

<MarshalAs(Unma nagedType.ByVal TStr, SizeConst:=260) > _
Public ArcName As String

<MarshalAs(Unma nagedType.ByVal TStr, 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(L ayoutKind.Seque ntial, CharSet:=CharSe t.Ansi)>_
Private Structure RAROpenArchiveD ata
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 RAROpenArchiveD ata) 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 RARSetChangeVol Proc 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.blueyond er.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.blueyond er.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.O P_EXTRACT
txtOut.text += "Extracting " & sStat
Ret = RARProcessFile( lHandle, RAR_EXTRACT, "D:\TestFolder\ Dump",
uHeader.FileNam e.ToString)
Case RarOperations.O P_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
3018
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
1387
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
12249
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 suites my needs. Do you know where to find such an api or dll? All it needs to do is ->uncompressing<- the major archiv files as well as reading...
4
10490
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)... however always if I want to execute the RARReadHeader Function I get "Object reference not set to an instance of an object" What do I wrong, I used...
2
10514
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 using System; using System.Runtime.InteropServices;
2
1527
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
513
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 dll I get a Null exception on the "ReadRARHeader" function.
0
2020
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 successfully start a program that prompts for a password, and then submit the password via SendKeys. SendKeys will work with both console and...
1
6526
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
7815
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7738
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8077
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8257
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7828
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8113
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6476
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5634
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3755
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...

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.