StormLib API Reference

SFileOpenArchive

Description

bool WINAPI SFileOpenArchive(
  const char * szMpqName,           // Archive file name
  DWORD dwPriority,                 // Archive priority
  DWORD dwFlags,                    // Open flags
  HANDLE * phMPQ                    // Pointer to result HANDLE
);

Function SFileOpenArchive opens a MPQ archive. During the open operation, the archive is checked for corruptions, internal (listfile) and (attributes) are loaded, unless specified otherwise. The archive is open for read and write operations, unless MPQ_OPEN_READ_ONLY is specified.

Note that StormLib maintains list of all files within the MPQ, as long as the MPQ is open. At the moment of MPQ opening, when the MPQ contains an internal list file, that listfile is parsed and all files in the listfile are checked against the hash table. Every file name that exists within the MPQ is added to the internal name list. The name list can be fuhrter extended by calling SFileAddListFile.

Parameters

szMpqName
[in] Archive file name to open.
dwPriority
[in] Priority of the archive for later search. StormLib does not use this parameter, set it to zero.
dwFlags
[in] Flags that specify additional options about how to open the file. They can have these values:
Value Meaning
MPQ_OPEN_NO_LISTFILE
(0x0010)
Don't read the internal listfile.
MPQ_OPEN_NO_ATTRIBUTES
(0x0020)
Don't open the "(attributes)" file.
MPQ_OPEN_FORCE_MPQ_V1
(0x0040)
Forces the MPQ to be open as MPQ format 1.0, ignoring "wFormatVersion" variable in the header.
MPQ_OPEN_CHECK_SECTOR_CRC
(0x0080)
SFileReadFile will check CRC of each file sector on any file in the archive until the archive is closed.
MPQ_OPEN_READ_ONLY
(0x0100)
Only reading from the archive is allowed. Any write operation will fail and GetLastError() returns ERROR_ACCESS_DENIED.
When calling this function in Storm.dll, set this parameter to zero.
phMPQ
[out] Pointer to a variable of HANDLE type, where the opened archive handle will be stored.

Return Value

When the function succeeds, it returns nonzero and phMPQ contains the handle of the opened archive. When the archive cannot be open, function returns false and GetLastError gives the error code.

Availability in Storm.dll

Available in Storm.dll Yes
Ordinal number in Storm.dll 1.00 63 (0x03F)
Ordinal number in Storm.dll 1.09 266 (0x10A)