StormLib API Reference



bool WINAPI SFileCreateArchive2(
  const TCHAR * szMpqName,          // Archive file name
  PSFILE_CREATE_MPQ pCreateInfo,    // Creation parameters
  HANDLE * phMPQ                    // Pointer to result archive handle

Function SFileCreateArchive opens or creates the MPQ archive. The function can also convert an existing file to MPQ archive. The MPQ archive is always open for write operations.

The function internally verifies the file using SFileOpenArchive. If the file already exists and it is an MPQ archive, the function fails and GetLastError() returns ERROR_ALREADY_EXISTS.


[in] Archive file name to be created.
[in] Pointer to structure of type SFILE_CREATE_MPQ that contains additional create parameters. The structure has the following members:
Member Meaning
cbSize Contains size of the structure. Initialize it to sizeof(SFILE_CREATE_MPQ).
dwMpqVersion Version for the newly created MPQ. 0 = version 1.0, 1 = version 2.0, 2 = version 3.0, 3 = version 4.0.
pvUserData and cbUserData Reserved. Do not use.
dwStreamFlags Stream flags for the new stream. Use one of STREAM_PROVIDER_XXX values and one of BASE_PROVIDER_XXX flags.
dwFileFlags1 MPQ file flags for the (listfile). Set this to 0 if you dont want to have listfile.
dwFileFlags2 MPQ file flags for the (attributes). Set this to 0 if you dont want to have attributes file.
dwFileFlags3 MPQ file flags for the (signature). A value of MPQ_FILE_EXISTS causes the archive to be signed by weak signature.
dwAttrFlags Combination of MPQ_ATTRIBUTE_XXX flags. Value of 0 suppresses creation of (attributes).
dwSectorSize Sector size for the compressed files. Must be a power of two.
dwRawChunkSize Size of raw data chunk. Used only if the MPQ is of version 4.0. Each raw chunk is followed by a MD5 hash.
dwMaxFileCount Maximum number of files that can be stored in the new MPQ.
[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 new archive. On an error, the function returns false and GetLastError gives the error code.

Availability in Storm.dll

Available in Storm.dll No
Ordinal number in Storm.dll 1.00 N/A
Ordinal number in Storm.dll 1.09 N/A