📄 sfmpqapi.bas
字号:
Attribute VB_Name = "SFmpqapi"
Option Explicit
' ShadowFlare MPQ API Library. (c) ShadowFlare Software 2002
' All functions below are actual functions that are part of this
' library and do not need any additional dll files. It does not
' even require Storm to be able to decompress or compress files.
' This library emulates the interface of Lmpqapi and Storm MPQ
' functions, so it may be used as a replacement for them in
' MPQ extractors/archivers without even needing to recompile
' the program that uses Lmpqapi or Storm. It has a few features
' not included in Lmpqapi and Storm, such as extra flags for some
' functions, setting the locale ID of existing files, and adding
' files without having to write them somewhere else first. Also,
' MPQ handles used by functions prefixed with "SFile" and "Mpq"
' can be used interchangably; all functions use the same type
' of MPQ handles. You cannot, however, use handles from this
' library with storm or lmpqapi or vice-versa. Doing so will
' most likely result in a crash.
' Revision History:
' 06/12/2002 1.07 (ShadowFlare)
' - No longer requires Storm.dll to compress or decompress
' Warcraft III files
' - Added SFileListFiles for getting names and information
' about all of the files in an archive
' - Fixed a bug with renaming and deleting files
' - Fixed a bug with adding wave compressed files with
' low compression setting
' - Added a check in MpqOpenArchiveForUpdate for proper
' dwMaximumFilesInArchive values (should be a number that
' is a power of 2). If it is not a proper value, it will
' be rounded up to the next higher power of 2
' 05/09/2002 1.06 (ShadowFlare)
' - Compresses files without Storm.dll!
' - If Warcraft III is installed, this library will be able to
' find Storm.dll on its own. (Storm.dll is needed to
' decompress Warcraft III files)
' - Fixed a bug where an embedded archive and the file that
' contains it would be corrupted if the archive was modified
' - Able to open all .w3m maps now
' 29/06/2002 1.05 (ShadowFlare)
' - Supports decompressing files from Warcraft III MPQ archives
' if using Storm.dll from Warcraft III
' - Added MpqAddFileToArchiveEx and MpqAddFileFromBufferEx for
' using extra compression types
' 29/05/2002 1.04 (ShadowFlare)
' - Files can be compressed now!
' - Fixed a bug in SFileReadFile when reading data not aligned
' to the block size
' - Optimized some of SFileReadFile's code. It can read files
' faster now
' - SFile functions may now be used to access files not in mpq
' archives as you can with the real storm functions
' - MpqCompactArchive will no longer corrupt files with the
' MODCRYPTKEY flag as long as the file is either compressed,
' listed in "(listfile)", is "(listfile)", or is located in
' the same place in the compacted archive; so it is safe
' enough to use it on almost any archive
' - Added MpqAddWaveFromBuffer
' - Better handling of archives with no files
' - Fixed compression with COMPRESS2 flag
' 15/05/2002 1.03 (ShadowFlare)
' - Supports adding files with the compression attribute (does
' not actually compress files). Now archives created with
' this dll can have files added to them through lmpqapi
' without causing staredit to crash
' - SFileGetBasePath and SFileSetBasePath work more like their
' Storm equivalents now
' - Implemented MpqCompactArchive, but it is not finished yet.
' In its current state, I would recommend against using it
' on archives that contain files with the MODCRYPTKEY flag,
' since it will corrupt any files with that flag
' - Added SFMpqGetVersionString2 which may be used in Visual
' Basic to get the version string
' 07/05/2002 1.02 (ShadowFlare)
' - SFileReadFile no longer passes the lpOverlapped parameter it
' receives to ReadFile. This is what was causing the function
' to fail when used in Visual Basic
' - Added support for more Storm MPQ functions
' - GetLastError may now be used to get information about why a
' function failed
' 01/05/2002 1.01 (ShadowFlare)
' - Added ordinals for Storm MPQ functions
' - Fixed MPQ searching functionality of SFileOpenFileEx
' - Added a check for whether a valid handle is given when
' SFileCloseArchive is called
' - Fixed functionality of SFileSetArchivePriority when multiple
' files are open
' - File renaming works for all filenames now
' - SFileReadFile no longer reallocates the buffer for each block
' that is decompressed. This should make SFileReadFile at least
' a little faster
' 30/04/2002 1.00 (ShadowFlare)
' - First version.
' - Compression not yet supported
' - Does not use SetLastError yet, so GetLastError will not return any
' errors that have to do with this library
' - MpqCompactArchive not implemented
' This library is freeware, you can do anything you want with it but with
' one exception. If you use it in your program, you must specify this fact
' in Help|About box or in similar way. You can obtain version string using
' SFMpqGetVersionString call.
' THIS LIBRARY IS DISTRIBUTED "AS IS". NO WARRANTY OF ANY KIND IS EXPRESSED
' OR IMPLIED. YOU USE AT YOUR OWN RISK. THE AUTHOR WILL NOT BE LIABLE FOR
' DATA LOSS, DAMAGES, LOSS OF PROFITS OR ANY OTHER KIND OF LOSS WHILE USING
' OR MISUSING THIS SOFTWARE.
' Any comments or suggestions are accepted at blakflare@hotmail.com (ShadowFlare)
Type SFMPQVERSION
Major As Integer
Minor As Integer
Revision As Integer
Subrevision As Integer
End Type
' MpqInitialize does nothing. It is only provided for
' compatibility with MPQ archivers that use lmpqapi.
Declare Function MpqInitialize Lib "SFmpq.dll" () As Boolean
Declare Function MpqGetVersionString Lib "SFmpq.dll" () As String
Declare Function MpqGetVersion Lib "SFmpq.dll" () As Single
Declare Sub SFMpqDestroy Lib "SFmpq.dll" () ' This no longer needs to be called. It is only provided for compatibility with older versions
' SFMpqGetVersionString2's return value is the required length of the buffer plus
' the terminating null, so use SFMpqGetVersionString2(ByVal 0&, 0) to get the length.
Declare Function SFMpqGetVersionString Lib "SFmpq.dll" () As String
Declare Function SFMpqGetVersionString2 Lib "SFmpq.dll" (ByVal lpBuffer As String, ByVal dwBufferLength As Long) As Long
Declare Function SFMpqGetVersion Lib "SFmpq.dll" () As SFMPQVERSION
' General error codes
Public Const MPQ_ERROR_MPQ_INVALID As Long = &H85200065
Public Const MPQ_ERROR_FILE_NOT_FOUND As Long = &H85200066
Public Const MPQ_ERROR_DISK_FULL As Long = &H85200068 'Physical write file to MPQ failed. Not sure of exact meaning
Public Const MPQ_ERROR_HASH_TABLE_FULL As Long = &H85200069
Public Const MPQ_ERROR_ALREADY_EXISTS As Long = &H8520006A
Public Const MPQ_ERROR_BAD_OPEN_MODE As Long = &H8520006C 'When MOAU_READ_ONLY is used without MOAU_OPEN_EXISTING
Public Const MPQ_ERROR_COMPACT_ERROR As Long = &H85300001
' MpqOpenArchiveForUpdate flags
Public Const MOAU_CREATE_NEW As Long = &H0
Public Const MOAU_CREATE_ALWAYS As Long = &H8 'Was wrongly named MOAU_CREATE_NEW
Public Const MOAU_OPEN_EXISTING As Long = &H4
Public Const MOAU_OPEN_ALWAYS As Long = &H20
Public Const MOAU_READ_ONLY As Long = &H10 'Must be used with MOAU_OPEN_EXISTING
Public Const MOAU_MAINTAIN_LISTFILE As Long = &H1
' MpqOpenArchiveForUpdateEx constants
Public Const DEFAULT_BLOCK_SIZE As Long = 3 ' 512 << number = block size
Public Const USE_DEFAULT_BLOCK_SIZE As Long = &HFFFF ' Use default block size that is defined internally
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -