Current News
Archived News
Search News
Discussion Forum


Old Forum
Install Programs More Downloads...
Troubleshooting
Source Code
Format Specs.
Misc. Information
Non-SF Stuff
Links




CommitLineData
940e7cf7 1Attribute VB_Name = "SFmpqapi"\r
2Option Explicit\r
3\r
a9771b7c 4' ShadowFlare MPQ API Library. (c) ShadowFlare Software 2002-2009\r
5' License information for this code is in license.txt and\r
6' included in this file at the end of this comment.\r
940e7cf7 7\r
8' All functions below are actual functions that are part of this\r
9' library and do not need any additional dll files. It does not\r
10' even require Storm to be able to decompress or compress files.\r
11\r
12' This library emulates the interface of Lmpqapi and Storm MPQ\r
13' functions, so it may be used as a replacement for them in\r
14' MPQ extractors/archivers without even needing to recompile\r
15' the program that uses Lmpqapi or Storm. It has a few features\r
16' not included in Lmpqapi and Storm, such as extra flags for some\r
17' functions, setting the locale ID of existing files, and adding\r
18' files without having to write them somewhere else first. Also,\r
19' MPQ handles used by functions prefixed with "SFile" and "Mpq"\r
20' can be used interchangably; all functions use the same type\r
21' of MPQ handles. You cannot, however, use handles from this\r
22' library with storm or lmpqapi or vice-versa. Doing so will\r
23' most likely result in a crash.\r
24\r
25' Revision History:\r
a9771b7c 26' (Release date) 1.08 (ShadowFlare)\r
27' - Fixed a buffer overflow that would occur when reading files\r
28' if neither using a buffer that is large enough to contain the\r
29' entire file nor has a size that is a multiple of 4096\r
30' - Added SFileOpenFileAsArchive which opens an archive that is\r
31' contained within an already open archive\r
32' - Added MpqRenameAndSetFileLocale and MpqDeleteFileWithLocale.\r
33' These have extra parameters that allow you to use them with\r
34' files having language codes other than what was last set\r
35' using SFileSetLocale\r
36' - Fixed a bug that caused (listfile) to get cleared if adding\r
37' files with a locale ID other than 0\r
38' - Added MpqOpenArchiveForUpdateEx which allows creating\r
39' archives with different block sizes\r
40' - SFileListFiles can list the contents of bncache.dat without\r
41' needing an external list\r
42\r
940e7cf7 43' 06/12/2002 1.07 (ShadowFlare)\r
44' - No longer requires Storm.dll to compress or decompress\r
45' Warcraft III files\r
46' - Added SFileListFiles for getting names and information\r
47' about all of the files in an archive\r
48' - Fixed a bug with renaming and deleting files\r
49' - Fixed a bug with adding wave compressed files with\r
50' low compression setting\r
51' - Added a check in MpqOpenArchiveForUpdate for proper\r
52' dwMaximumFilesInArchive values (should be a number that\r
53' is a power of 2). If it is not a proper value, it will\r
54' be rounded up to the next higher power of 2\r
55\r
56' 05/09/2002 1.06 (ShadowFlare)\r
57' - Compresses files without Storm.dll!\r
58' - If Warcraft III is installed, this library will be able to\r
59' find Storm.dll on its own. (Storm.dll is needed to\r
60' decompress Warcraft III files)\r
61' - Fixed a bug where an embedded archive and the file that\r
62' contains it would be corrupted if the archive was modified\r
63' - Able to open all .w3m maps now\r
64\r
65' 29/06/2002 1.05 (ShadowFlare)\r
66' - Supports decompressing files from Warcraft III MPQ archives\r
67' if using Storm.dll from Warcraft III\r
68' - Added MpqAddFileToArchiveEx and MpqAddFileFromBufferEx for\r
69' using extra compression types\r
70\r
71' 29/05/2002 1.04 (ShadowFlare)\r
72' - Files can be compressed now!\r
73' - Fixed a bug in SFileReadFile when reading data not aligned\r
74' to the block size\r
75' - Optimized some of SFileReadFile's code. It can read files\r
76' faster now\r
77' - SFile functions may now be used to access files not in mpq\r
78' archives as you can with the real storm functions\r
79' - MpqCompactArchive will no longer corrupt files with the\r
80' MODCRYPTKEY flag as long as the file is either compressed,\r
81' listed in "(listfile)", is "(listfile)", or is located in\r
82' the same place in the compacted archive; so it is safe\r
83' enough to use it on almost any archive\r
84' - Added MpqAddWaveFromBuffer\r
85' - Better handling of archives with no files\r
86' - Fixed compression with COMPRESS2 flag\r
87\r
88' 15/05/2002 1.03 (ShadowFlare)\r
89' - Supports adding files with the compression attribute (does\r
90' not actually compress files). Now archives created with\r
91' this dll can have files added to them through lmpqapi\r
92' without causing staredit to crash\r
93' - SFileGetBasePath and SFileSetBasePath work more like their\r
94' Storm equivalents now\r
95' - Implemented MpqCompactArchive, but it is not finished yet.\r
96' In its current state, I would recommend against using it\r
97' on archives that contain files with the MODCRYPTKEY flag,\r
98' since it will corrupt any files with that flag\r
99' - Added SFMpqGetVersionString2 which may be used in Visual\r
100' Basic to get the version string\r
101\r
102' 07/05/2002 1.02 (ShadowFlare)\r
103' - SFileReadFile no longer passes the lpOverlapped parameter it\r
104' receives to ReadFile. This is what was causing the function\r
105' to fail when used in Visual Basic\r
106' - Added support for more Storm MPQ functions\r
107' - GetLastError may now be used to get information about why a\r
108' function failed\r
109\r
110' 01/05/2002 1.01 (ShadowFlare)\r
111' - Added ordinals for Storm MPQ functions\r
112' - Fixed MPQ searching functionality of SFileOpenFileEx\r
113' - Added a check for whether a valid handle is given when\r
114' SFileCloseArchive is called\r
115' - Fixed functionality of SFileSetArchivePriority when multiple\r
116' files are open\r
117' - File renaming works for all filenames now\r
118' - SFileReadFile no longer reallocates the buffer for each block\r
119' that is decompressed. This should make SFileReadFile at least\r
120' a little faster\r
121\r
122' 30/04/2002 1.00 (ShadowFlare)\r
123' - First version.\r
124' - Compression not yet supported\r
125' - Does not use SetLastError yet, so GetLastError will not return any\r
126' errors that have to do with this library\r
127' - MpqCompactArchive not implemented\r
128\r
129' Any comments or suggestions are accepted at blakflare@hotmail.com (ShadowFlare)\r
130\r
a9771b7c 131' License information:\r
132\r
133' Copyright (c) 2002-2009, ShadowFlare <blakflare@hotmail.com>\r
134' All rights reserved.\r
135\r
136' Redistribution and use in source and binary forms, with or without\r
137' modification, are permitted provided that the following conditions\r
138' are met:\r
139\r
140' 1. Redistributions of source code must retain the above copyright\r
141' notice, this list of conditions and the following disclaimer.\r
142' 2. Redistributions in binary form must reproduce the above copyright\r
143' notice, this list of conditions and the following disclaimer in the\r
144' documentation and/or other materials provided with the distribution.\r
145\r
146' THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND\r
147' ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
148' IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
149' ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\r
150' FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
151' DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r
152' OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
153' HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
154' LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r
155' OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r
156' SUCH DAMAGE.\r
157\r
940e7cf7 158Type SFMPQVERSION\r
159 Major As Integer\r
160 Minor As Integer\r
161 Revision As Integer\r
162 Subrevision As Integer\r
163End Type\r
164\r
165' MpqInitialize does nothing. It is only provided for\r
166' compatibility with MPQ archivers that use lmpqapi.\r
167Declare Function MpqInitialize Lib "SFmpq.dll" () As Boolean\r
168\r
169Declare Function MpqGetVersionString Lib "SFmpq.dll" () As String\r
170Declare Function MpqGetVersion Lib "SFmpq.dll" () As Single\r
171\r
172Declare Sub SFMpqDestroy Lib "SFmpq.dll" () ' This no longer needs to be called. It is only provided for compatibility with older versions\r
173\r
a9771b7c 174Declare Sub AboutSFMpq Lib "SFmpq.dll" () ' Displays an about page in a web browser (this has only been tested in Internet Explorer). This is only for the dll version of SFmpq\r
175\r
940e7cf7 176' SFMpqGetVersionString2's return value is the required length of the buffer plus\r
177' the terminating null, so use SFMpqGetVersionString2(ByVal 0&, 0) to get the length.\r
178Declare Function SFMpqGetVersionString Lib "SFmpq.dll" () As String\r
179Declare Function SFMpqGetVersionString2 Lib "SFmpq.dll" (ByVal lpBuffer As String, ByVal dwBufferLength As Long) As Long\r
180Declare Function SFMpqGetVersion Lib "SFmpq.dll" () As SFMPQVERSION\r
181\r
182' General error codes\r
183Public Const MPQ_ERROR_MPQ_INVALID As Long = &H85200065\r
184Public Const MPQ_ERROR_FILE_NOT_FOUND As Long = &H85200066\r
185Public Const MPQ_ERROR_DISK_FULL As Long = &H85200068 'Physical write file to MPQ failed. Not sure of exact meaning\r
186Public Const MPQ_ERROR_HASH_TABLE_FULL As Long = &H85200069\r
187Public Const MPQ_ERROR_ALREADY_EXISTS As Long = &H8520006A\r
188Public Const MPQ_ERROR_BAD_OPEN_MODE As Long = &H8520006C 'When MOAU_READ_ONLY is used without MOAU_OPEN_EXISTING\r
189\r
190Public Const MPQ_ERROR_COMPACT_ERROR As Long = &H85300001\r
191\r
192' MpqOpenArchiveForUpdate flags\r
193Public Const MOAU_CREATE_NEW As Long = &H0\r
194Public Const MOAU_CREATE_ALWAYS As Long = &H8 'Was wrongly named MOAU_CREATE_NEW\r
195Public Const MOAU_OPEN_EXISTING As Long = &H4\r
196Public Const MOAU_OPEN_ALWAYS As Long = &H20\r
197Public Const MOAU_READ_ONLY As Long = &H10 'Must be used with MOAU_OPEN_EXISTING\r
a9771b7c 198Public Const MOAU_MAINTAIN_ATTRIBUTES As Long = &H2 'Will be used in a future version to create the (attributes) file\r
940e7cf7 199Public Const MOAU_MAINTAIN_LISTFILE As Long = &H1\r
200\r
a9771b7c 201' MpqOpenArchiveForUpdateEx constants\r
202Public Const DEFAULT_BLOCK_SIZE As Long = 3 ' 512 << number = block size\r
203Public Const USE_DEFAULT_BLOCK_SIZE As Long = &HFFFF ' Use default block size that is defined internally\r
204\r
940e7cf7 205' MpqAddFileToArchive flags\r
206Public Const MAFA_EXISTS As Long = &H80000000 'Will be added if not present\r
207Public Const MAFA_UNKNOWN40000000 As Long = &H40000000\r
208Public Const MAFA_MODCRYPTKEY As Long = &H20000\r
209Public Const MAFA_ENCRYPT As Long = &H10000\r
210Public Const MAFA_COMPRESS As Long = &H200\r
211Public Const MAFA_COMPRESS2 As Long = &H100\r
212Public Const MAFA_REPLACE_EXISTING As Long = &H1\r
213\r
214' MpqAddFileToArchiveEx compression flags\r
215Public Const MAFA_COMPRESS_STANDARD As Long = &H8 'Standard PKWare DCL compression\r
216Public Const MAFA_COMPRESS_DEFLATE As Long = &H2 'ZLib's deflate compression\r
a9771b7c 217Public Const MAFA_COMPRESS_BZIP2 As Long = &H10 'bzip2 compression\r
218Public Const MAFA_COMPRESS_WAVE As Long = &H81 'Stereo wave compression\r
219Public Const MAFA_COMPRESS_WAVE2 As Long = &H41 'Mono wave compression\r
940e7cf7 220\r
221' Flags for individual compression types used for wave compression\r
a9771b7c 222Public Const MAFA_COMPRESS_WAVECOMP1 As Long = &H80 'Main compressor for stereo wave compression\r
223Public Const MAFA_COMPRESS_WAVECOMP2 As Long = &H40 'Main compressor for mono wave compression\r
940e7cf7 224Public Const MAFA_COMPRESS_WAVECOMP3 As Long = &H1 'Secondary compressor for wave compression\r
225\r
226' ZLib deflate compression level constants (used with MpqAddFileToArchiveEx and MpqAddFileFromBufferEx)\r
227Public Const Z_NO_COMPRESSION As Long = 0\r
228Public Const Z_BEST_SPEED As Long = 1\r
229Public Const Z_BEST_COMPRESSION As Long = 9\r
230Public Const Z_DEFAULT_COMPRESSION As Long = (-1)\r
231\r
232' MpqAddWAVToArchive quality flags\r
233Public Const MAWA_QUALITY_HIGH As Long = 1\r
234Public Const MAWA_QUALITY_MEDIUM As Long = 0\r
235Public Const MAWA_QUALITY_LOW As Long = 2\r
236\r
237' SFileGetFileInfo flags\r
238Public Const SFILE_INFO_BLOCK_SIZE As Long = &H1 'Block size in MPQ\r
239Public Const SFILE_INFO_HASH_TABLE_SIZE As Long = &H2 'Hash table size in MPQ\r
240Public Const SFILE_INFO_NUM_FILES As Long = &H3 'Number of files in MPQ\r
241Public Const SFILE_INFO_TYPE As Long = &H4 'Is Long a file or an MPQ?\r
242Public Const SFILE_INFO_SIZE As Long = &H5 'Size of MPQ or uncompressed file\r
243Public Const SFILE_INFO_COMPRESSED_SIZE As Long = &H6 'Size of compressed file\r
244Public Const SFILE_INFO_FLAGS As Long = &H7 'File flags (compressed, etc.), file attributes if a file not in an archive\r
245Public Const SFILE_INFO_PARENT As Long = &H8 'Handle of MPQ that file is in\r
246Public Const SFILE_INFO_POSITION As Long = &H9 'Position of file pointer in files\r
247Public Const SFILE_INFO_LOCALEID As Long = &HA 'Locale ID of file in MPQ\r
248Public Const SFILE_INFO_PRIORITY As Long = &HB 'Priority of open MPQ\r
249Public Const SFILE_INFO_HASH_INDEX As Long = &HC 'Hash index of file in MPQ\r
a9771b7c 250Public Const SFILE_INFO_BLOCK_INDEX As Long = &HD 'Block table index of file in MPQ\r
251\r
252' Return values of SFileGetFileInfo when SFILE_INFO_TYPE flag is used\r
253Public Const SFILE_TYPE_MPQ As Long = &H1\r
254Public Const SFILE_TYPE_FILE As Long = &H2\r
940e7cf7 255\r
256' SFileListFiles flags\r
257Public Const SFILE_LIST_MEMORY_LIST As Long = &H1 ' Specifies that lpFilelists is a file list from memory, rather than being a list of file lists\r
258Public Const SFILE_LIST_ONLY_KNOWN As Long = &H2 ' Only list files that the function finds a name for\r
259Public Const SFILE_LIST_ONLY_UNKNOWN As Long = &H4 ' Only list files that the function does not find a name for\r
a9771b7c 260Public Const SFILE_LIST_FLAG_UNKNOWN As Long = &H8 ' Use without SFILE_LIST_ONLY_KNOWN or SFILE_LIST_FLAG_UNKNOWN to list all files, but will set dwFileExists to 3 if file's name is not found\r
940e7cf7 261\r
262Public Const INVALID_HANDLE_VALUE As Long = -1\r
263\r
264Public Const FILE_BEGIN As Long = 0\r
265Public Const FILE_CURRENT As Long = 1\r
266Public Const FILE_END As Long = 2\r
267\r
a9771b7c 268' SFileOpenArchive flags\r
940e7cf7 269Public Const SFILE_OPEN_HARD_DISK_FILE As Long = &H0 'Open archive without regard to the drive type it resides on\r
270Public Const SFILE_OPEN_CD_ROM_FILE As Long = &H1 'Open the archive only if it is on a CD-ROM\r
271Public Const SFILE_OPEN_ALLOW_WRITE As Long = &H8000 'Open file with write access\r
272\r
a9771b7c 273' SFileOpenFileEx search scopes\r
940e7cf7 274Public Const SFILE_SEARCH_CURRENT_ONLY As Long = &H0 'Used with SFileOpenFileEx; only the archive with the handle specified will be searched for the file\r
275Public Const SFILE_SEARCH_ALL_OPEN As Long = &H1 'SFileOpenFileEx will look through all open archives for the file\r
276\r
277Type FILELISTENTRY\r
278 dwFileExists As Long ' Nonzero if this entry is used\r
279 lcLocale As Long ' Locale ID of file\r
280 dwCompressedSize As Long ' Compressed size of file\r
281 dwFullSize As Long ' Uncompressed size of file\r
282 dwFlags As Long ' Flags for file\r
283 szFileName(259) As Byte\r
284End Type\r
285\r
286' Storm functions implemented by this library\r
287Declare Function SFileOpenArchive Lib "SFmpq.dll" (ByVal lpFileName As String, ByVal dwPriority As Long, ByVal dwFlags As Long, ByRef hMPQ As Long) As Boolean\r
288Declare Function SFileCloseArchive Lib "SFmpq.dll" (ByVal hMPQ As Long) As Boolean\r
a9771b7c 289Declare Function SFileOpenFileAsArchive Lib "SFmpq.dll" (ByVal hSourceMPQ As Long, ByVal lpFileName As String, ByVal dwPriority As Long, ByVal dwFlags As Long, ByRef hMPQ As Long) As Boolean\r
940e7cf7 290Declare Function SFileGetArchiveName Lib "SFmpq.dll" (ByVal hMPQ As Long, ByVal lpBuffer As String, ByVal dwBufferLength As Long) As Boolean\r
291Declare Function SFileOpenFile Lib "SFmpq.dll" (ByVal lpFileName As String, ByRef hFile As Long) As Boolean\r
292Declare Function SFileOpenFileEx Lib "SFmpq.dll" (ByVal hMPQ As Long, ByVal lpFileName As String, ByVal dwSearchScope As Long, ByRef hFile As Long) As Boolean\r
293Declare Function SFileCloseFile Lib "SFmpq.dll" (ByVal hFile As Long) As Boolean\r
294Declare Function SFileGetFileSize Lib "SFmpq.dll" (ByVal hFile As Long, lpFileSizeHigh As Long) As Long\r
295Declare Function SFileGetFileArchive Lib "SFmpq.dll" (ByVal hFile As Long, ByRef hMPQ As Long) As Boolean\r
296Declare Function SFileGetFileName Lib "SFmpq.dll" (ByVal hMPQ As Long, ByVal lpBuffer As String, ByVal dwBufferLength As Long) As Boolean\r
297Declare Function SFileSetFilePointer Lib "SFmpq.dll" (ByVal hFile As Long, ByVal lDistanceToMove As Long, lplDistanceToMoveHigh As Long, ByVal dwMoveMethod As Long) As Long\r
a9771b7c 298Declare Function SFileReadFile Lib "SFmpq.dll" (ByVal hFile As Long, ByRef lpBuffer As Any, ByVal nNumberOfBytesToRead As Long, lpNumberOfBytesRead As Long, ByRef lpOverlapped As Any) As Boolean\r
940e7cf7 299Declare Function SFileSetLocale Lib "SFmpq.dll" (ByVal nNewLocale As Long) As Long\r
300Declare Function SFileGetBasePath Lib "SFmpq.dll" (ByVal lpBuffer As String, ByVal dwBufferLength As Long) As Boolean\r
301Declare Function SFileSetBasePath Lib "SFmpq.dll" (ByVal lpNewBasePath As String) As Boolean\r
302\r
303' Extra storm-related functions\r
304Declare Function SFileGetFileInfo Lib "SFmpq.dll" (ByVal hFile As Long, ByVal dwInfoType As Long) As Long\r
305Declare Function SFileSetArchivePriority Lib "SFmpq.dll" (ByVal hMPQ As Long, ByVal dwPriority As Long) As Boolean\r
306Declare Function SFileFindMpqHeader Lib "SFmpq.dll" (ByVal hFile As Long) As Long\r
307Declare Function SFileListFiles Lib "SFmpq.dll" (ByVal hMPQ As Long, ByVal lpFileLists As String, ByRef lpListBuffer As FILELISTENTRY, ByVal dwFlags As Long) As Boolean\r
308\r
309' Archive editing functions implemented by this library\r
310Declare Function MpqOpenArchiveForUpdate Lib "SFmpq.dll" (ByVal lpFileName As String, ByVal dwFlags As Long, ByVal dwMaximumFilesInArchive As Long) As Long\r
311Declare Function MpqCloseUpdatedArchive Lib "SFmpq.dll" (ByVal hMPQ As Long, ByVal dwUnknown2 As Long) As Long\r
312Declare Function MpqAddFileToArchive Lib "SFmpq.dll" (ByVal hMPQ As Long, ByVal lpSourceFileName As String, ByVal lpDestFileName As String, ByVal dwFlags As Long) As Boolean\r
313Declare Function MpqAddWaveToArchive Lib "SFmpq.dll" (ByVal hMPQ As Long, ByVal lpSourceFileName As String, ByVal lpDestFileName As String, ByVal dwFlags As Long, ByVal dwQuality As Long) As Boolean\r
314Declare Function MpqRenameFile Lib "SFmpq.dll" (ByVal hMPQ As Long, ByVal lpcOldFileName As String, ByVal lpcNewFileName As String) As Boolean\r
315Declare Function MpqDeleteFile Lib "SFmpq.dll" (ByVal hMPQ As Long, ByVal lpFileName As String) As Boolean\r
316Declare Function MpqCompactArchive Lib "SFmpq.dll" (ByVal hMPQ As Long) As Boolean\r
317\r
318' Extra archive editing functions\r
a9771b7c 319Declare Function MpqOpenArchiveForUpdateEx Lib "SFmpq.dll" (ByVal lpFileName As String, ByVal dwFlags As Long, ByVal dwMaximumFilesInArchive As Long, ByVal dwBlockSize As Long) As Long\r
940e7cf7 320Declare Function MpqAddFileToArchiveEx Lib "SFmpq.dll" (ByVal hMPQ As Long, ByVal lpSourceFileName As String, ByVal lpDestFileName As String, ByVal dwFlags As Long, ByVal dwCompressionType As Long, ByVal dwCompressLevel As Long) As Boolean\r
a9771b7c 321Declare Function MpqAddFileFromBufferEx Lib "SFmpq.dll" (ByVal hMPQ As Long, ByRef lpBuffer As Any, ByVal dwLength As Long, ByVal lpFileName As String, ByVal dwFlags As Long, ByVal dwCompressionType As Long, ByVal dwCompressLevel As Long) As Boolean\r
322Declare Function MpqAddFileFromBuffer Lib "SFmpq.dll" (ByVal hMPQ As Long, ByRef lpBuffer As Any, ByVal dwLength As Long, ByVal lpFileName As String, ByVal dwFlags As Long) As Boolean\r
323Declare Function MpqAddWaveFromBuffer Lib "SFmpq.dll" (ByVal hMPQ As Long, ByRef lpBuffer As Any, ByVal dwLength As Long, ByVal lpFileName As String, ByVal dwFlags As Long, ByVal dwQuality As Long) As Boolean\r
324Declare Function MpqRenameAndSetFileLocale Lib "SFmpq.dll" (ByVal hMPQ As Long, ByVal lpcOldFileName As String, ByVal lpcNewFileName As String, ByVal nOldLocale As Long, ByVal nNewLocale As Long) As Boolean\r
325Declare Function MpqDeleteFileWithLocale Lib "SFmpq.dll" (ByVal hMPQ As Long, ByVal lpFileName As String, ByVal nLocale As Long) As Boolean\r
940e7cf7 326Declare Function MpqSetFileLocale Lib "SFmpq.dll" (ByVal hMPQ As Long, ByVal lpFileName As String, ByVal nOldLocale As Long, ByVal nNewLocale As Long) As Boolean\r
327\r
328' These functions do nothing. They are only provided for\r
329' compatibility with MPQ extractors that use storm.\r
330Declare Function SFileDestroy Lib "SFmpq.dll" () As Boolean\r
331Declare Sub StormDestroy Lib "SFmpq.dll" ()\r
332\r
333' Returns 0 if the dll version is equal to the version your program was compiled\r
334' with, 1 if the dll is newer, -1 if the dll is older.\r
335Function SFMpqCompareVersion() As Long\r
336 Dim ExeVersion As SFMPQVERSION, DllVersion As SFMPQVERSION\r
337 With ExeVersion\r
338 .Major = 1\r
339 .Minor = 0\r
a9771b7c 340 .Revision = 8\r
341 .Subrevision = 1\r
940e7cf7 342 End With\r
343 DllVersion = SFMpqGetVersion()\r
344 If DllVersion.Major > ExeVersion.Major Then\r
345 SFMpqCompareVersion = 1\r
346 Exit Function\r
347 ElseIf DllVersion.Major < ExeVersion.Major Then\r
348 SFMpqCompareVersion = -1\r
349 Exit Function\r
350 End If\r
351 If DllVersion.Minor > ExeVersion.Minor Then\r
352 SFMpqCompareVersion = 1\r
353 Exit Function\r
354 ElseIf DllVersion.Minor < ExeVersion.Minor Then\r
355 SFMpqCompareVersion = -1\r
356 Exit Function\r
357 End If\r
358 If DllVersion.Revision > ExeVersion.Revision Then\r
359 SFMpqCompareVersion = 1\r
360 Exit Function\r
361 ElseIf DllVersion.Revision < ExeVersion.Revision Then\r
362 SFMpqCompareVersion = -1\r
363 Exit Function\r
364 End If\r
365 If DllVersion.Subrevision > ExeVersion.Subrevision Then\r
366 SFMpqCompareVersion = 1\r
367 Exit Function\r
368 ElseIf DllVersion.Subrevision < ExeVersion.Subrevision Then\r
369 SFMpqCompareVersion = -1\r
370 Exit Function\r
371 End If\r
372 SFMpqCompareVersion = 0\r
373End Function\r
374\r