468,720 Members | 1,502 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,720 developers. It's quick & easy.

new code

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>
/// Summary description for Class1.
/// </summary>
class Class1
{
public const int ERAR_END_ARCHIVE = 10;
public const int ERAR_NO_MEMORY = 11;
public const int ERAR_BAD_DATA = 12;
public const int ERAR_BAD_ARCHIVE = 13;
public const int ERAR_UNKNOWN_FORMAT = 14;
public const int ERAR_EOPEN = 15;
public const int ERAR_ECREATE = 16;
public const int ERAR_ECLOSE = 17;
public const int ERAR_EREAD = 18;
public const int ERAR_EWRITE = 19;
public const int ERAR_SMALL_BUF = 20;

public const int RAR_OM_LIST = 0;
public const int RAR_OM_EXTRACT = 1;

public const int RAR_SKIP = 0;
public const int RAR_TEST = 1;
public const int RAR_EXTRACT = 2;

public const int RAR_VOL_ASK = 0;
public const int RAR_VOL_NOTIFY = 1;

public enum RarOperations
{
OP_EXTRACT = 0,
OP_TEST = 1,
OP_LIST = 2
}

public struct RARHeaderData
{

[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
public string ArcName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
public string FileName;

public uint Flags;
public uint PackSize;
public uint UnpSize;
public uint HostOS;
public uint FileCRC;
public uint FileTime;
public uint UnpVer;
public uint Method;
public uint FileAttr;
public string CmtBuf;
public uint CmtBufSize;
public uint CmtSize;
public uint CmtState;
}

public struct RAROpenArchiveData
{
public string ArcName;
public uint OpenMode;
public uint OpenResult;
public string CmtBuf;
public uint CmtBufSize;
public uint CmtSize;
public uint CmtState;
}

public struct RAROpenArchiveDataEx
{
public string ArcName;
public string ArcNameW;
public uint OpenMode;
public uint OpenResult;
public string CmtBuf;
public uint CmtBufSize;
public uint CmtSize;
public uint CmtState;
public uint Flags;
public uint Reserved;
}
public struct RARHeaderDataEx
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
public string ArcName;

public string ArcNameW;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
public string FileName;

public string FileNameW;
public uint Flags;
public uint PackSize;
public uint PackSizeHigh;
public uint UnpSize;
public uint UnpSizeHigh;
public uint HostOS;
public uint FileCRC;
public uint FileTime;
public uint UnpVer;
public uint Method;
public uint FileAttr;
public string CmtBuf;
public uint CmtBufSize;
public uint CmtSize;
public uint CmtState;
public uint Reserved;
};
[DllImportAttribute("unrar.dll")]
public static extern unsafe IntPtr RAROpenArchive (ref
RAROpenArchiveData ArchiveData);
[DllImportAttribute("unrar.dll")]
public static extern unsafe int RARCloseArchive(IntPtr hArcData);
[DllImportAttribute("unrar.dll")]
public static extern unsafe int RARReadHeader (IntPtr hArcData, ref

RARHeaderData HeaderData);
[DllImportAttribute("unrar.dll")]
public static extern unsafe IntPtr RAROpenArchiveEx(ref
RAROpenArchiveDataEx ArchiveData);
[DllImportAttribute("unrar.dll")]
public static extern unsafe int RARReadHeaderEx(IntPtr hArcData, ref

RARHeaderDataEx HeaderData);
[DllImportAttribute("unrar.dll")]
public static extern unsafe int RARProcessFile(IntPtr hArcData, int

Operation, string DestPath, string DestName);
[DllImportAttribute("unrar.dll")]
public static extern unsafe int RARGetDllVersion();
[DllImportAttribute("unrar.dll")]
public static extern unsafe int RARSetPassword(IntPtr
hArcData,string Password);

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
IntPtr lHandle;
int iStatus;
RARHeaderData uHeader;
RAROpenArchiveData uRAR;
uint openresult=0;
uint cmt=0;
uRAR.ArcName = @"D:\b.rar";
uRAR.CmtBuf = string.Empty.PadLeft(16384,' ');
uRAR.CmtBufSize = 16384;
uRAR.OpenMode=RAR_OM_EXTRACT;
uRAR.OpenResult=openresult;
uRAR.CmtState=cmt;
uRAR.CmtSize=4;
////////////////////////////
uHeader=new RARHeaderData();

lHandle = RAROpenArchive(ref uRAR);
Console.WriteLine("OpenResult: {0}",uRAR.OpenResult);
Console.WriteLine("CmtState: {0}",uRAR.CmtState);
String s = @"d:";
String n=string.Empty;
RARProcessFile(lHandle,RAR_EXTRACT,s,n);
iStatus=RARReadHeader(lHandle, ref uHeader);
Console.WriteLine("Status: {0}",iStatus);

iStatus = RARCloseArchive(lHandle);

Console.WriteLine("Status: {0}",iStatus);
Console.WriteLine("HostOs:{0}",uHeader.FileName);
Console.ReadLine();

//
// TODO: Add code to start application here
//
}
}
}

----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Nov 15 '05 #1
2 1444
you may get more help from
http://www.rarlab.com

This looks like a fairly application specific problem.

--- Nick

"mmmobasher" <mm********@yahoo-dot-com.no-spam.invalid> wrote in message
news:40**********@127.0.0.1...
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>
/// Summary description for Class1.
/// </summary>
class Class1
{
public const int ERAR_END_ARCHIVE = 10;
public const int ERAR_NO_MEMORY = 11;
public const int ERAR_BAD_DATA = 12;
public const int ERAR_BAD_ARCHIVE = 13;
public const int ERAR_UNKNOWN_FORMAT = 14;
public const int ERAR_EOPEN = 15;
public const int ERAR_ECREATE = 16;
public const int ERAR_ECLOSE = 17;
public const int ERAR_EREAD = 18;
public const int ERAR_EWRITE = 19;
public const int ERAR_SMALL_BUF = 20;

public const int RAR_OM_LIST = 0;
public const int RAR_OM_EXTRACT = 1;

public const int RAR_SKIP = 0;
public const int RAR_TEST = 1;
public const int RAR_EXTRACT = 2;

public const int RAR_VOL_ASK = 0;
public const int RAR_VOL_NOTIFY = 1;

public enum RarOperations
{
OP_EXTRACT = 0,
OP_TEST = 1,
OP_LIST = 2
}

public struct RARHeaderData
{

[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
public string ArcName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
public string FileName;

public uint Flags;
public uint PackSize;
public uint UnpSize;
public uint HostOS;
public uint FileCRC;
public uint FileTime;
public uint UnpVer;
public uint Method;
public uint FileAttr;
public string CmtBuf;
public uint CmtBufSize;
public uint CmtSize;
public uint CmtState;
}

public struct RAROpenArchiveData
{
public string ArcName;
public uint OpenMode;
public uint OpenResult;
public string CmtBuf;
public uint CmtBufSize;
public uint CmtSize;
public uint CmtState;
}

public struct RAROpenArchiveDataEx
{
public string ArcName;
public string ArcNameW;
public uint OpenMode;
public uint OpenResult;
public string CmtBuf;
public uint CmtBufSize;
public uint CmtSize;
public uint CmtState;
public uint Flags;
public uint Reserved;
}
public struct RARHeaderDataEx
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
public string ArcName;

public string ArcNameW;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
public string FileName;

public string FileNameW;
public uint Flags;
public uint PackSize;
public uint PackSizeHigh;
public uint UnpSize;
public uint UnpSizeHigh;
public uint HostOS;
public uint FileCRC;
public uint FileTime;
public uint UnpVer;
public uint Method;
public uint FileAttr;
public string CmtBuf;
public uint CmtBufSize;
public uint CmtSize;
public uint CmtState;
public uint Reserved;
};
[DllImportAttribute("unrar.dll")]
public static extern unsafe IntPtr RAROpenArchive (ref
RAROpenArchiveData ArchiveData);
[DllImportAttribute("unrar.dll")]
public static extern unsafe int RARCloseArchive(IntPtr hArcData);
[DllImportAttribute("unrar.dll")]
public static extern unsafe int RARReadHeader (IntPtr hArcData, ref

RARHeaderData HeaderData);
[DllImportAttribute("unrar.dll")]
public static extern unsafe IntPtr RAROpenArchiveEx(ref
RAROpenArchiveDataEx ArchiveData);
[DllImportAttribute("unrar.dll")]
public static extern unsafe int RARReadHeaderEx(IntPtr hArcData, ref

RARHeaderDataEx HeaderData);
[DllImportAttribute("unrar.dll")]
public static extern unsafe int RARProcessFile(IntPtr hArcData, int

Operation, string DestPath, string DestName);
[DllImportAttribute("unrar.dll")]
public static extern unsafe int RARGetDllVersion();
[DllImportAttribute("unrar.dll")]
public static extern unsafe int RARSetPassword(IntPtr
hArcData,string Password);

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
IntPtr lHandle;
int iStatus;
RARHeaderData uHeader;
RAROpenArchiveData uRAR;
uint openresult=0;
uint cmt=0;
uRAR.ArcName = @"D:\b.rar";
uRAR.CmtBuf = string.Empty.PadLeft(16384,' ');
uRAR.CmtBufSize = 16384;
uRAR.OpenMode=RAR_OM_EXTRACT;
uRAR.OpenResult=openresult;
uRAR.CmtState=cmt;
uRAR.CmtSize=4;
////////////////////////////
uHeader=new RARHeaderData();

lHandle = RAROpenArchive(ref uRAR);
Console.WriteLine("OpenResult: {0}",uRAR.OpenResult);
Console.WriteLine("CmtState: {0}",uRAR.CmtState);
String s = @"d:";
String n=string.Empty;
RARProcessFile(lHandle,RAR_EXTRACT,s,n);
iStatus=RARReadHeader(lHandle, ref uHeader);
Console.WriteLine("Status: {0}",iStatus);

iStatus = RARCloseArchive(lHandle);

Console.WriteLine("Status: {0}",iStatus);
Console.WriteLine("HostOs:{0}",uHeader.FileName);
Console.ReadLine();

//
// TODO: Add code to start application here
//
}
}
}

----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption

=---
Nov 15 '05 #2
"mmmobasher" <mm********@yahoo-dot-com.no-spam.invalid> wrote in message
news:40**********@127.0.0.1...
finaly this code seems to work but it doesn't extract anything and
flags returns success, any oponion?


Here's the fix:

http://www.csharp-station.com/ShowPost.aspx?PostID=3470

Joe
--
http://www.csharp-station.com
Nov 15 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

51 posts views Thread by Mudge | last post: by
9 posts views Thread by bigoxygen | last post: by
4 posts views Thread by jason | last post: by
16 posts views Thread by Dario de Judicibus | last post: by
109 posts views Thread by Andrew Thompson | last post: by
18 posts views Thread by Joe Fallon | last post: by
171 posts views Thread by tshad | last post: by
9 posts views Thread by bryonone | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.