473,699 Members | 2,272 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_ARCHIV E = 10;
public const int ERAR_NO_MEMORY = 11;
public const int ERAR_BAD_DATA = 12;
public const int ERAR_BAD_ARCHIV E = 13;
public const int ERAR_UNKNOWN_FO RMAT = 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(Unman agedType.ByValT Str, SizeConst = 260)]
public string ArcName;
[MarshalAs(Unman agedType.ByValT Str, 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 RAROpenArchiveD ata
{
public string ArcName;
public uint OpenMode;
public uint OpenResult;
public string CmtBuf;
public uint CmtBufSize;
public uint CmtSize;
public uint CmtState;
}

public struct RAROpenArchiveD ataEx
{
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(Unman agedType.ByValT Str, SizeConst = 260)]
public string ArcName;

public string ArcNameW;
[MarshalAs(Unman agedType.ByValT Str, 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;
};
[DllImportAttrib ute("unrar.dll" )]
public static extern unsafe IntPtr RAROpenArchive (ref
RAROpenArchiveD ata ArchiveData);
[DllImportAttrib ute("unrar.dll" )]
public static extern unsafe int RARCloseArchive (IntPtr hArcData);
[DllImportAttrib ute("unrar.dll" )]
public static extern unsafe int RARReadHeader (IntPtr hArcData, ref

RARHeaderData HeaderData);
[DllImportAttrib ute("unrar.dll" )]
public static extern unsafe IntPtr RAROpenArchiveE x(ref
RAROpenArchiveD ataEx ArchiveData);
[DllImportAttrib ute("unrar.dll" )]
public static extern unsafe int RARReadHeaderEx (IntPtr hArcData, ref

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

Operation, string DestPath, string DestName);
[DllImportAttrib ute("unrar.dll" )]
public static extern unsafe int RARGetDllVersio n();
[DllImportAttrib ute("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;
RAROpenArchiveD ata uRAR;
uint openresult=0;
uint cmt=0;
uRAR.ArcName = @"D:\b.rar";
uRAR.CmtBuf = string.Empty.Pa dLeft(16384,' ');
uRAR.CmtBufSize = 16384;
uRAR.OpenMode=R AR_OM_EXTRACT;
uRAR.OpenResult =openresult;
uRAR.CmtState=c mt;
uRAR.CmtSize=4;
////////////////////////////
uHeader=new RARHeaderData() ;

lHandle = RAROpenArchive( ref uRAR);
Console.WriteLi ne("OpenResult : {0}",uRAR.OpenR esult);
Console.WriteLi ne("CmtState: {0}",uRAR.CmtSt ate);
String s = @"d:";
String n=string.Empty;
RARProcessFile( lHandle,RAR_EXT RACT,s,n);
iStatus=RARRead Header(lHandle, ref uHeader);
Console.WriteLi ne("Status: {0}",iStatus);

iStatus = RARCloseArchive (lHandle);

Console.WriteLi ne("Status: {0}",iStatus);
Console.WriteLi ne("HostOs:{0}" ,uHeader.FileNa me);
Console.ReadLin e();

//
// 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 1529
you may get more help from
http://www.rarlab.com

This looks like a fairly application specific problem.

--- Nick

"mmmobasher " <mm********@yah oo-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_ARCHIV E = 10;
public const int ERAR_NO_MEMORY = 11;
public const int ERAR_BAD_DATA = 12;
public const int ERAR_BAD_ARCHIV E = 13;
public const int ERAR_UNKNOWN_FO RMAT = 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(Unman agedType.ByValT Str, SizeConst = 260)]
public string ArcName;
[MarshalAs(Unman agedType.ByValT Str, 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 RAROpenArchiveD ata
{
public string ArcName;
public uint OpenMode;
public uint OpenResult;
public string CmtBuf;
public uint CmtBufSize;
public uint CmtSize;
public uint CmtState;
}

public struct RAROpenArchiveD ataEx
{
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(Unman agedType.ByValT Str, SizeConst = 260)]
public string ArcName;

public string ArcNameW;
[MarshalAs(Unman agedType.ByValT Str, 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;
};
[DllImportAttrib ute("unrar.dll" )]
public static extern unsafe IntPtr RAROpenArchive (ref
RAROpenArchiveD ata ArchiveData);
[DllImportAttrib ute("unrar.dll" )]
public static extern unsafe int RARCloseArchive (IntPtr hArcData);
[DllImportAttrib ute("unrar.dll" )]
public static extern unsafe int RARReadHeader (IntPtr hArcData, ref

RARHeaderData HeaderData);
[DllImportAttrib ute("unrar.dll" )]
public static extern unsafe IntPtr RAROpenArchiveE x(ref
RAROpenArchiveD ataEx ArchiveData);
[DllImportAttrib ute("unrar.dll" )]
public static extern unsafe int RARReadHeaderEx (IntPtr hArcData, ref

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

Operation, string DestPath, string DestName);
[DllImportAttrib ute("unrar.dll" )]
public static extern unsafe int RARGetDllVersio n();
[DllImportAttrib ute("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;
RAROpenArchiveD ata uRAR;
uint openresult=0;
uint cmt=0;
uRAR.ArcName = @"D:\b.rar";
uRAR.CmtBuf = string.Empty.Pa dLeft(16384,' ');
uRAR.CmtBufSize = 16384;
uRAR.OpenMode=R AR_OM_EXTRACT;
uRAR.OpenResult =openresult;
uRAR.CmtState=c mt;
uRAR.CmtSize=4;
////////////////////////////
uHeader=new RARHeaderData() ;

lHandle = RAROpenArchive( ref uRAR);
Console.WriteLi ne("OpenResult : {0}",uRAR.OpenR esult);
Console.WriteLi ne("CmtState: {0}",uRAR.CmtSt ate);
String s = @"d:";
String n=string.Empty;
RARProcessFile( lHandle,RAR_EXT RACT,s,n);
iStatus=RARRead Header(lHandle, ref uHeader);
Console.WriteLi ne("Status: {0}",iStatus);

iStatus = RARCloseArchive (lHandle);

Console.WriteLi ne("Status: {0}",iStatus);
Console.WriteLi ne("HostOs:{0}" ,uHeader.FileNa me);
Console.ReadLin e();

//
// 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********@yah oo-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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

51
5262
by: Mudge | last post by:
Please, someone, tell me why OO in PHP is better than procedural.
9
3864
by: bigoxygen | last post by:
Hi. I'm using a 3 tier FrontController Design for my web application right now. The problem is that I'm finding to have to duplicate a lot of code for similar functions; for example, listing users, and listing assignments use similar type commands. Is there a "better" way I can organize my code?
4
2431
by: jason | last post by:
Hello. Newbie on SQL and suffering through this. I have two tables created as such: drop table table1; go drop table table2; go
16
3103
by: Dario de Judicibus | last post by:
I'm getting crazy. Look at this code: #include <string.h> #include <stdio.h> #include <iostream.h> using namespace std ; char ini_code = {0xFF, 0xFE} ; char line_sep = {0x20, 0x28} ;
109
5890
by: Andrew Thompson | last post by:
It seems most people get there JS off web sites, which is entirely logical. But it is also a great pity since most of that code is of such poor quality. I was looking through the JS FAQ for any question that identifies the warning signs to look out for, the things that most easily and clearly identify the author of code as something less than a master of the art. I did not find an FAQ that answered it, but I think the FAQ
5
4065
by: ED | last post by:
I currently have vba code that ranks employees based on their average job time ordered by their region, zone, and job code. I currently have vba code that will cycle through a query and ranks each employee based on their region, zone, job code and avg job time. (See code below). My problem is that I do not know how to rank the ties. Right now if two people have the same avg time one will be ranked 3rd and the other ranked 4th. I would...
0
2091
by: Namratha Shah \(Nasha\) | last post by:
Hey Guys, Today we are going to look at Code Access Security. Code access security is a feature of .NET that manages code depending on its trust level. If the CLS trusts the code enough to allow it ro run then it will execute, the code execution depends on the permission provided to the assembly. If the code is not trusted wnough to run or it attempts to perform an action which doe not have the required permissions then its execution...
18
3156
by: Joe Fallon | last post by:
I have some complex logic which is fairly simply to build up into a string. I needed a way to Eval this string and return a Boolean result. This code works fine to achieve that goal. My question is what happens to the dynamically created assembly when the method is done running? Does GC take care of it? Or is it stuck in RAM until the ASP.Net process is recycled? This code executes pretty frequently (maybe 4 times per transaction) and...
37
5966
by: Alan Silver | last post by:
Hello, Newbie here, so please forgive what is probably a basic question ... I see a lot of discussion about "code behind", which if I have understood correctly, means that the script code goes in a separate file from the HTML. Apart from the obvious advantage if you have a separate designer and programmer, are there any other advantages to code behind? Most of the stuff I've seen so far uses code inside, but that's probably
171
7727
by: tshad | last post by:
I am just trying to decide whether to split my code and uses code behind. I did it with one of my pages and found it was quite a bit of trouble. I know that most people (and books and articles) like it because you can split the code from the design. That is logical. But if you are the only one working on the code, it seem a little overkill. I use Dreamweaver to do my design and find it a bit of a hassle to have multiple files open...
0
8706
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8631
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8902
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7787
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5889
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4392
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4641
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3075
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2366
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.