Re: UnRAROCX.ocx and unrar.dll

From: Ben S (benscarboro_at_hotmail.com)
Date: 02/02/04


Date: Mon, 2 Feb 2004 20:09:48 -0000

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.


Relevant Pages

  • Re: Vb Global variables
    ... You'll want to Add a Module, then declare the variable in the ... 'Global gsPathToData As String ... Sub Form_Load, and Private Sub Command1_Click. ...
    (microsoft.public.vb.general.discussion)
  • Re: MsgBox Function and Private Variables
    ... While you can declare the variable outside of a routine, ... In other words, your Private ... DateEarly as String can go in the Declaration section, ... Doug Steele, Microsoft Access MVP ...
    (microsoft.public.access.formscoding)
  • Re: MsgBox Function and Private Variables
    ... While you can declare the variable outside of a routine, ... In other words, your Private ... DateEarly as String can go in the Declaration section, ... MsgBox("The date cannot be before the review date. ...
    (microsoft.public.access.formscoding)
  • Re: public vs. shared
    ... when you declare dim variable as string in the class scope, ... default access modifier (which is private). ... end sub ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Global/Public
    ... If they are public to the whole project, accessible from any module, declare ... Public Const myConst as Integer = 1 ... If they are private to the module, accessible only to that module, declares ... Private myString as String ...
    (microsoft.public.excel.programming)

Loading