|
|
|
|
|
|
|
|
A
P P E N D I XA
MPQS for
Visual
Basic
|
|
|
|
|
The
introduction to this section needs to be written.
|
|
|
|
Using
the Storm API |
|
|
|
|
The declarations you will need to
use the Storm MPQ functions in Visual Basic were converted by ShadowFlare and are
located on her site.
Click
here to download the Storm Visual Basic declarations
To use the
Storm functions, add Storm.bas to your Visual Basic project.
This appendix only explains the differences
between using Storm in Visual Basic and C++ and a few of the parameters that are listed as
unknown in the other chapters. For an explanation on how to use the functions, refer to
chapter 3.
|
|
|
|
Using StarEdit - The MPQ API
Library |
|
|
|
|
The declarations you will need to
use the MPQ API Library 2.0 in Visual Basic were converted by ShadowFlare and are
located on her site.
Click
here to download the Lmpqapi Visual Basic declarations
To use the
Lmpqapi functions, add Lmpqapi.bas to your Visual Basic project.
There are no particular differences between
using the MPQ API Library in Visual Basic and C++ that need to be discussed here. For an
explanation on how to use the functions, refer to chapter 4.
|
|
|
|
Opening
an MPQ Archive - SFileOpenArchive |
|
|
|
|
Function
SFileOpenArchive(lpFileName As String,
dwPriority As Long, dwFlags As Long,
hMPQ As Long) As Boolean
|
|
Parameter |
What it is |
|
|
lpFileName |
[in] A pointer to a
string that holds the path of the MPQ to open. SFileOpenArchive
will crash if this is NULL. |
|
|
dwPriority |
[in] When multiple archives are open
at once, this parameter defines the order in which SFileOpenFile and SFileOpenFileEx
will search the archives for a file. Higher numbers are checked first. |
|
|
dwFlags |
Flags that specify conditions for opening
the archive. The following values are currently known to be used:
2 (defined as SFILE_OPEN_HARD_DISK_FILE) |
This value is used by Starcraft but does not seem to do anything different than any other values. If this is used, the function will open the archive without regard to the drive type it resides on. |
3 (defined as SFILE_OPEN_CD_ROM_FILE) |
This causes the function to only open the archive only if it is on a CD-ROM. |
|
|
|
hMPQ |
[out] Upon successful completion, this
will hold the HANDLE of the MPQ. SFileOpenArchive will fail if this
is NULL. |
|
|
|
|
|
Opening
a File Inside an MPQ - SFileOpenFileEx |
|
|
|
|
Function
SFileOpenFileEx(hMPQ As Long,
lpFileName As String, dwSearchScope As Long,
hFile As Long) As Boolean
|
|
Parameter |
What
it is |
|
|
hMPQ |
[in] The HANDLE of
the MPQ previously opened with SFileOpenArchive that contains
the file you want to open. Setting this to NULL is equivalent
to using a search scope of 1. |
|
|
lpFileName |
[in] A pointer to a NULL
terminated string that holds name of the file within the MPQ to be
opened. SFileOpenFileEx will crash if this is NULL. |
|
|
dwSearchScope |
[in] Specifies where to
look for a file when opening a file on the hard drive. When working with MPQs,
use 0 to only look for the file in the archive specified and 1 (or possibly any
non-zero value) to look in all open archives for the file. |
|
|
hFile |
[out] Upon successful completion, this
will hold the HANDLE of the requested file. SFileOpenFileEx will
fail if this is NULL. |
|
|
|
|
|
Reading
from a File in an MPQ - SFileReadFile |
|
|
|
|
Function
SFileReadFile(hFile As Long,
lpBuffer As Byte, nNumberOfBytesToRead As Long,
lpNumberOfBytesRead As Long,
lpOverlapped As Any) As Boolean
|
|
Parameter |
What it is |
|
|
hFile |
[in] The HANDLE of
the file to read from, which was acquired earlier with SFileOpenFileEx.
SFileReadFile will crash if this is NULL or a HANDLE
not obtained with SFileOpenFileEx. |
|
|
lpBuffer |
[out] A pointer to a
buffer in memory where SFileReadFile will place the data read
from the file. This buffer must be at least as large as nNumberOfBytesToRead.
SFileReadFile will fail if this is NULL. |
|
|
nNumberOfBytesToRead |
[in] The number of bytes
for SFileReadFile to read from the file. SFileReadFile
may crash if this is larger than the size of lpBuffer. |
|
|
lpNumberOfBytesRead |
[out] A variable
that will hold the number of bytes actually read from the file. The
number of bytes read will never be more than nNumberOfBytesToRead,
but may be less if the number of unread bytes in the file is less
than nNumberOfBytesToRead. It is not recommended to let this
be NULL. |
|
|
lpOverlapped |
[in] A pointer to an OVERLAPPED
structure. This is used for asynchronous reading of files on a disk,
and must be NULL when reading files in MPQs. |
|
To use this function, declare a byte array large enough for the data to read and pass the
first element of the array to the function (lpBuffer(0)).
|
|