⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sfmpqapi.bas

📁 能处理星际争霸
💻 BAS
📖 第 1 页 / 共 2 页
字号:

' MpqAddFileToArchive flags
Public Const MAFA_EXISTS As Long = &H80000000 'Will be added if not present
Public Const MAFA_UNKNOWN40000000 As Long = &H40000000
Public Const MAFA_MODCRYPTKEY As Long = &H20000
Public Const MAFA_ENCRYPT As Long = &H10000
Public Const MAFA_COMPRESS As Long = &H200
Public Const MAFA_COMPRESS2 As Long = &H100
Public Const MAFA_REPLACE_EXISTING As Long = &H1

' MpqAddFileToArchiveEx compression flags
Public Const MAFA_COMPRESS_STANDARD As Long = &H8 'Standard PKWare DCL compression
Public Const MAFA_COMPRESS_DEFLATE  As Long = &H2 'ZLib's deflate compression
Public Const MAFA_COMPRESS_WAVE    As Long = &H81 'Standard wave compression
Public Const MAFA_COMPRESS_WAVE2   As Long = &H41 'Unused wave compression

' Flags for individual compression types used for wave compression
Public Const MAFA_COMPRESS_WAVECOMP1 As Long = &H80 'Main compressor for standard wave compression
Public Const MAFA_COMPRESS_WAVECOMP2 As Long = &H40 'Main compressor for unused wave compression
Public Const MAFA_COMPRESS_WAVECOMP3  As Long = &H1 'Secondary compressor for wave compression

' ZLib deflate compression level constants (used with MpqAddFileToArchiveEx and MpqAddFileFromBufferEx)
Public Const Z_NO_COMPRESSION         As Long = 0
Public Const Z_BEST_SPEED             As Long = 1
Public Const Z_BEST_COMPRESSION       As Long = 9
Public Const Z_DEFAULT_COMPRESSION  As Long = (-1)

' MpqAddWAVToArchive quality flags
Public Const MAWA_QUALITY_HIGH As Long = 1
Public Const MAWA_QUALITY_MEDIUM As Long = 0
Public Const MAWA_QUALITY_LOW As Long = 2

' SFileGetFileInfo flags
Public Const SFILE_INFO_BLOCK_SIZE As Long = &H1 'Block size in MPQ
Public Const SFILE_INFO_HASH_TABLE_SIZE As Long = &H2 'Hash table size in MPQ
Public Const SFILE_INFO_NUM_FILES As Long = &H3 'Number of files in MPQ
Public Const SFILE_INFO_TYPE As Long = &H4 'Is Long a file or an MPQ?
Public Const SFILE_INFO_SIZE As Long = &H5 'Size of MPQ or uncompressed file
Public Const SFILE_INFO_COMPRESSED_SIZE As Long = &H6 'Size of compressed file
Public Const SFILE_INFO_FLAGS As Long = &H7 'File flags (compressed, etc.), file attributes if a file not in an archive
Public Const SFILE_INFO_PARENT As Long = &H8 'Handle of MPQ that file is in
Public Const SFILE_INFO_POSITION As Long = &H9 'Position of file pointer in files
Public Const SFILE_INFO_LOCALEID As Long = &HA 'Locale ID of file in MPQ
Public Const SFILE_INFO_PRIORITY As Long = &HB 'Priority of open MPQ
Public Const SFILE_INFO_HASH_INDEX As Long = &HC 'Hash index of file in MPQ

' SFileListFiles flags
Public 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
Public Const SFILE_LIST_ONLY_KNOWN   As Long = &H2 ' Only list files that the function finds a name for
Public Const SFILE_LIST_ONLY_UNKNOWN As Long = &H4 ' Only list files that the function does not find a name for

Public Const SFILE_TYPE_MPQ As Long = &H1
Public Const SFILE_TYPE_FILE As Long = &H2

Public Const INVALID_HANDLE_VALUE As Long = -1

Public Const FILE_BEGIN   As Long = 0
Public Const FILE_CURRENT As Long = 1
Public Const FILE_END     As Long = 2

Public Const SFILE_OPEN_HARD_DISK_FILE As Long = &H0 'Open archive without regard to the drive type it resides on
Public Const SFILE_OPEN_CD_ROM_FILE As Long = &H1 'Open the archive only if it is on a CD-ROM
Public Const SFILE_OPEN_ALLOW_WRITE As Long = &H8000 'Open file with write access

Public Const SFILE_SEARCH_CURRENT_ONLY As Long = &H0 'Used with SFileOpenFileEx; only the archive with the handle specified will be searched for the file
Public Const SFILE_SEARCH_ALL_OPEN As Long = &H1 'SFileOpenFileEx will look through all open archives for the file

Type FILELISTENTRY
    dwFileExists As Long ' Nonzero if this entry is used
    lcLocale As Long ' Locale ID of file
    dwCompressedSize As Long ' Compressed size of file
    dwFullSize As Long ' Uncompressed size of file
    dwFlags As Long ' Flags for file
    szFileName(259) As Byte
End Type

' Storm functions implemented by this library
Declare Function SFileOpenArchive Lib "SFmpq.dll" (ByVal lpFileName As String, ByVal dwPriority As Long, ByVal dwFlags As Long, ByRef hMPQ As Long) As Boolean
Declare Function SFileCloseArchive Lib "SFmpq.dll" (ByVal hMPQ As Long) As Boolean
Declare Function SFileGetArchiveName Lib "SFmpq.dll" (ByVal hMPQ As Long, ByVal lpBuffer As String, ByVal dwBufferLength As Long) As Boolean
Declare Function SFileOpenFile Lib "SFmpq.dll" (ByVal lpFileName As String, ByRef hFile As Long) As Boolean
Declare Function SFileOpenFileEx Lib "SFmpq.dll" (ByVal hMPQ As Long, ByVal lpFileName As String, ByVal dwSearchScope As Long, ByRef hFile As Long) As Boolean
Declare Function SFileCloseFile Lib "SFmpq.dll" (ByVal hFile As Long) As Boolean
Declare Function SFileGetFileSize Lib "SFmpq.dll" (ByVal hFile As Long, lpFileSizeHigh As Long) As Long
Declare Function SFileGetFileArchive Lib "SFmpq.dll" (ByVal hFile As Long, ByRef hMPQ As Long) As Boolean
Declare Function SFileGetFileName Lib "SFmpq.dll" (ByVal hMPQ As Long, ByVal lpBuffer As String, ByVal dwBufferLength As Long) As Boolean
Declare Function SFileSetFilePointer Lib "SFmpq.dll" (ByVal hFile As Long, ByVal lDistanceToMove As Long, lplDistanceToMoveHigh As Long, ByVal dwMoveMethod As Long) As Long
Declare 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
Declare Function SFileSetLocale Lib "SFmpq.dll" (ByVal nNewLocale As Long) As Long
Declare Function SFileGetBasePath Lib "SFmpq.dll" (ByVal lpBuffer As String, ByVal dwBufferLength As Long) As Boolean
Declare Function SFileSetBasePath Lib "SFmpq.dll" (ByVal lpNewBasePath As String) As Boolean

' Extra storm-related functions
Declare Function SFileGetFileInfo Lib "SFmpq.dll" (ByVal hFile As Long, ByVal dwInfoType As Long) As Long
Declare Function SFileSetArchivePriority Lib "SFmpq.dll" (ByVal hMPQ As Long, ByVal dwPriority As Long) As Boolean
Declare Function SFileFindMpqHeader Lib "SFmpq.dll" (ByVal hFile As Long) As Long
Declare Function SFileListFiles Lib "SFmpq.dll" (ByVal hMPQ As Long, ByVal lpFileLists As String, ByRef lpListBuffer As FILELISTENTRY, ByVal dwFlags As Long) As Boolean

' Archive editing functions implemented by this library
Declare Function MpqOpenArchiveForUpdate Lib "SFmpq.dll" (ByVal lpFileName As String, ByVal dwFlags As Long, ByVal dwMaximumFilesInArchive As Long) As Long
Declare Function MpqCloseUpdatedArchive Lib "SFmpq.dll" (ByVal hMPQ As Long, ByVal dwUnknown2 As Long) As Long
Declare Function MpqAddFileToArchive Lib "SFmpq.dll" (ByVal hMPQ As Long, ByVal lpSourceFileName As String, ByVal lpDestFileName As String, ByVal dwFlags As Long) As Boolean
Declare 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
Declare Function MpqRenameFile Lib "SFmpq.dll" (ByVal hMPQ As Long, ByVal lpcOldFileName As String, ByVal lpcNewFileName As String) As Boolean
Declare Function MpqDeleteFile Lib "SFmpq.dll" (ByVal hMPQ As Long, ByVal lpFileName As String) As Boolean
Declare Function MpqCompactArchive Lib "SFmpq.dll" (ByVal hMPQ As Long) As Boolean

' Extra archive editing functions
Declare Function MpqOpenArchiveForUpdateEx Lib "SFmpq.dll" (ByVal lpFileName As String, ByVal dwFlags As Long, ByVal dwMaximumFilesInArchive As Long, ByVal dwBlockSize As Long) As Long
Declare 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
Declare 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
Declare 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
Declare 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
Declare Function MpqSetFileLocale Lib "SFmpq.dll" (ByVal hMPQ As Long, ByVal lpFileName As String, ByVal nOldLocale As Long, ByVal nNewLocale As Long) As Boolean

' These functions do nothing.  They are only provided for
' compatibility with MPQ extractors that use storm.
Declare Function SFileDestroy Lib "SFmpq.dll" () As Boolean
Declare Sub StormDestroy Lib "SFmpq.dll" ()

' Returns 0 if the dll version is equal to the version your program was compiled
' with, 1 if the dll is newer, -1 if the dll is older.
Function SFMpqCompareVersion() As Long
    Dim ExeVersion As SFMPQVERSION, DllVersion As SFMPQVERSION
    With ExeVersion
        .Major = 1
        .Minor = 0
        .Revision = 7
        .Subrevision = 4
    End With
    DllVersion = SFMpqGetVersion()
    If DllVersion.Major > ExeVersion.Major Then
        SFMpqCompareVersion = 1
        Exit Function
    ElseIf DllVersion.Major < ExeVersion.Major Then
        SFMpqCompareVersion = -1
        Exit Function
    End If
    If DllVersion.Minor > ExeVersion.Minor Then
        SFMpqCompareVersion = 1
        Exit Function
    ElseIf DllVersion.Minor < ExeVersion.Minor Then
        SFMpqCompareVersion = -1
        Exit Function
    End If
    If DllVersion.Revision > ExeVersion.Revision Then
        SFMpqCompareVersion = 1
        Exit Function
    ElseIf DllVersion.Revision < ExeVersion.Revision Then
        SFMpqCompareVersion = -1
        Exit Function
    End If
    If DllVersion.Subrevision > ExeVersion.Subrevision Then
        SFMpqCompareVersion = 1
        Exit Function
    ElseIf DllVersion.Subrevision < ExeVersion.Subrevision Then
        SFMpqCompareVersion = -1
        Exit Function
    End If
    SFMpqCompareVersion = 0
End Function

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -