Free Pascal interface unit for UnRAR dll Ported to Free Pascal by Alex

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
// Free Pascal interface unit for UnRAR.dll
//
// Ported to Free Pascal by Alexey Fayans, fidonet: 2:5030/1997, e-mail: shad@shad.pp.ru
{$IFNDEF NO_SMART_LINK}
{$SMARTLINK ON}
{$ENDIF}
{$MODE objfpc}
{$CALLING stdcall}
{$PACKRECORDS C}
unit UnRAR;
interface
uses Windows;
const
ERAR_END_ARCHIVE = 10;
ERAR_NO_MEMORY = 11;
ERAR_BAD_DATA = 12;
ERAR_BAD_ARCHIVE = 13;
ERAR_UNKNOWN_FORMAT = 14;
ERAR_EOPEN = 15;
ERAR_ECREATE = 16;
ERAR_ECLOSE = 17;
ERAR_EREAD = 18;
ERAR_EWRITE = 19;
ERAR_SMALL_BUF = 20;
ERAR_UNKNOWN = 21;
RAR_OM_LIST = 0;
RAR_OM_EXTRACT = 1;
RAR_SKIP = 0;
RAR_TEST = 1;
RAR_EXTRACT = 2;
RAR_VOL_ASK = 0;
RAR_VOL_NOTIFY = 1;
RAR_DLL_VERSION = 3;
UCM_CHANGEVOLUME = 0;
UCM_PROCESSDATA = 1;
UCM_NEEDPASSWORD = 2;
type
PRARHeaderData = ^TRARHeaderData;
TRARHeaderData = record
ArcName: array[0..259] of Char;
FileName: array[0..259] of Char;
Flags: UInt;
PackSize: UInt;
UnpSize: UInt;
HostOS: UInt;
FileCRC: UInt;
FileTime: UInt;
UnpVer: UInt;
Method: UInt;
FileAttr: UInt;
CmtBuf: PChar;
CmtBufSize: UInt;
CmtSize: UInt;
CmtState: UInt;
end;
PRARHeaderDataEx = ^TRARHeaderDataEx;
TRARHeaderDataEx = record
ArcName: array [0..1023] of Char;
ArcNameW: array [0..1023] of WideChar;
FileName: array [0..1023] of Char;
FileNameW: array [0..1023] of WideChar;
Flags: UInt;
PackSize: UInt;
PackSizeHigh: UInt;
UnpSize: UInt;
UnpSizeHigh: UInt;
HostOS: UInt;
FileCRC: UInt;
FileTime: UInt;
UnpVer: UInt;
Method: UInt;
FileAttr: UInt;
CmtBuf: PChar;
CmtBufSize: UInt;
CmtSize: UInt;
CmtState: UInt;
Reserved: array [0..1023] of UInt;
end;
PRAROpenArchiveData = ^TRAROpenArchiveData;
TRAROpenArchiveData = record
ArcName: PChar;
OpenMode: UInt;
OpenResult: UInt;
CmtBuf: PChar;
CmtBufSize: UInt;
CmtSize: UInt;
CmtState: UInt;
end;
PRAROpenArchiveDataEx = ^TRAROpenArchiveDataEx;
TRAROpenArchiveDataEx = record
ArcName: PChar;
ArcNameW: PWideChar;
OpenMode: UInt;
OpenResult: UInt;
CmtBuf: PChar;
CmtBufSize: UInt;
CmtSize: UInt;
CmtState: UInt;
Flags: UInt;
Reserved: array [0..31] of UInt;
end;
TUnrarCallback = function(Msg: UInt; UserData, P1, P2: Longint): Integer;
function RAROpenArchive(ArchiveData: PRAROpenArchiveData): THandle;
function RAROpenArchiveEx(ArchiveData: PRAROpenArchiveDataEx): THandle;
function RARCloseArchive(hArcData: THandle): Integer;
function RARReadHeader(hArcData: THandle; HeaderData: PRARHeaderData): Integer;
function RARReadHeaderEx(hArcData: THandle; HeaderData: PRARHeaderDataEx): Integer;
function RARProcessFile(hArcData: THandle; Operation: Integer; DestPath, DestName: PChar): Integer;
function RARProcessFileW(hArcData: THandle; Operation: Integer; DestPath, DestName: PWideChar): Integer;
procedure RARSetCallback(hArcData: THandle; UnrarCallback: TUnrarCallback; UserData: Longint);
procedure RARSetPassword(hArcData: THandle; Password: PChar);
// obsolete functions
type
TChangeVolProc = function(ArcName: PChar; Mode: Integer): Integer;
TProcessDataProc = function(Addr: PUChar; Size: Integer): Integer;
procedure RARSetChangeVolProc(hArcData: THandle; ChangeVolProc: TChangeVolProc);
procedure RARSetProcessDataProc(hArcData: THandle; ProcessDataProc: TProcessDataProc);
implementation
function RAROpenArchive(ArchiveData: PRAROpenArchiveData): THandle;
external 'unrar.dll' name 'RAROpenArchive';
function RAROpenArchiveEx(ArchiveData: PRAROpenArchiveDataEx): THandle;
external 'unrar.dll' name 'RAROpenArchiveEx';
function RARCloseArchive(hArcData: THandle): Integer;
external 'unrar.dll' name 'RARCloseArchive';
function RARReadHeader(hArcData: THandle; HeaderData: PRARHeaderData): Integer;
external 'unrar.dll' name 'RARReadHeader';
function RARReadHeaderEx(hArcData: THandle; HeaderData: PRARHeaderDataEx): Integer;
external 'unrar.dll' name 'RARReadHeaderEx';
function RARProcessFile(hArcData: THandle; Operation: Integer; DestPath, DestName: PChar): Integer;
external 'unrar.dll' name 'RARProcessFile';
function RARProcessFileW(hArcData: THandle; Operation: Integer; DestPath, DestName: PWideChar): Integer;
external 'unrar.dll' name 'RARProcessFileW';
procedure RARSetCallback(hArcData: THandle; UnrarCallback: TUnrarCallback; UserData: Longint);
external 'unrar.dll' name 'RARSetCallback';
procedure RARSetPassword(hArcData: THandle; Password: PChar);
external 'unrar.dll' name 'RARSetPassword';
procedure RARSetChangeVolProc(hArcData: THandle; ChangeVolProc: TChangeVolProc);
external 'unrar.dll' name 'RARSetChangeVolProc';
procedure RARSetProcessDataProc(hArcData: THandle; ProcessDataProc: TProcessDataProc);
external 'unrar.dll' name 'RARSetProcessDataProc';
end.