StormLib API Reference

SFileOpenFileEx

Description

bool WINAPI SFileOpenFileEx(
  HANDLE hMpq,                      // Archive handle
  const char * szFileName,          // Name of the file to open
  DWORD dwSearchScope,              // Specifies the scope for the file.
  HANDLE * phFile                   // Pointer to file handle
);

Function SFileOpenFileEx opens a file from MPQ archive. The file is only open for read. The file must be closed by calling SFileCloseFile. All files must be closed before the MPQ archive is closed.

Parameters

hMpq
[in] Handle to an open archive.
szFileName
[in] Name or index of the file to open.
dwSearchScope
[in] Value that specifies how exactly the file should be open. It can be one of the following values:
Value Meaning
SFILE_OPEN_FROM_MPQ
(0x00000000)
The file is open from the MPQ. This is the default value. hMpq must be valid if SFILE_OPEN_FROM_MPQ is specified.
SFILE_OPEN_LOCAL_FILE
(0xFFFFFFFF)
Opens a local file instead. The file is open using CreateFileEx with GENERIC_READ access and FILE_SHARE_READ mode.
When calling this function in Storm.dll, set this parameter to zero.
phFile
[out] Pointer to a variable of HANDLE type, that will receive HANDLE to the open file.

Return Value

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

Remarks

The function always tries to open file with the specified locale first. If such file doesn't exist in the MPQ, the function tries to open file with neutral language ID.

When the archive is a patched archive, then the following StormLib functions behave dfferently:

When the caller doesn't know the proper file name, a pseudo name can be used. The pseudo name is in the form of File%08u.xxx (case sensitive). The numeric part of the file is the index in the file table. The open operation succeeds only if any of the following conditions is true:

Availability in Storm.dll

Available in Storm.dll Yes
Ordinal number in Storm.dll 1.00 79 (0x04F)
Ordinal number in Storm.dll 1.09 268 (0x10C)