WinMPQ v1.63

This program is an mpq archiver I started as an example of a program using the Mpq Control, but it now uses SFmpq directly.  It currently has many features and is one of the best mpq archivers around.

Required Files (all may be downloaded from my page)

•	Visual Basic 4 runtime libraries
•	Microsoft Windows Common Controls
•	SFmpq (included)

Mo'PaQ 2000 parameters and scripts in WinMPQ
WinMPQ has support for running Mo'PaQ 2000 (MPQ2k) parameters and scripts; it almost has full support for every parameter MPQ2k uses and has commands and additional features MPQ2k doesn't have.  Also, the name of the MPQ archive only needs to be specified when opening files and using command-line parameters.  (parts of this section are taken from the Mo'PaQ 2000 manual)

General syntax:
Filenames containing spaces must be enclosed in quotation marks like this:

"filename with spaces"

Adding Files - the Add Command
	The syntax for adding files is:

a[dd] <MPQFile> <SourceFile> [DestinationFile] [/c] [/wav] [/auto] [/r]

Parameters in <> are required, ones in [] are optional.  MPQFile is the MoPaQ to add the file(s) to.  SourceFile is the file(s) to add to the MoPaQ.  If there is only a single file being added (no wildcards are used), DestinationFile is the name that the file will be stored as in the MoPaQ.  But, if there are multiple files to add (wildcards are used), DestinationFile is the directory to put the files in.  /c tells WinMPQ to compress the file(s).  /wav tells WinMPQ to add the file with WAV compression, which is recommended for .WAV files (if both /c and /wav are used, /c will be ignored and /wav used).  /auto tells WinMPQ to automatically select the appropriate compression option for each file (if any other compression options are used, they will override this).  /r tells WinMPQ to recurse through subdirectories when searching for files to add.  If no DestinationFile is given, the file will be added with the same name as SourceFile.

Wildcard characters (* and ?) are used by many command-line programs to represent multiple files.  WinMPQ uses them currently only for the Add command.  Wildcards represent one or more unknown characters.  The ? wildcard stands for a single unknown character, while * wildcards stand for any number of unknown characters.

Extracting Files - the Extract Command
The syntax for the extract command is:

e[xtract] <MPQFile> <SourceFile> [DestinationDirectory] [/fp]

The parameters in <> are required, ones in [] are optional.  SourceFile is the FULL name of the file(s) to be extracted from the MoPaQ, and DestinationDirectory is the directory in which to put the extracted file(s).  If DestinationDirectory is absent, the file will be placed in the current directory.  Wildcards may be used in SourceFile.  The /r parameter MPQ2K uses currently isn't supported by WinMPQ.  The /fp parameter specifies that WinMPQ should extract the files with the full path.

Renaming Files - the Rename Command
The syntax for the rename command is:

r[ename] <MPQFile> <OldFileName> <NewFileName>

All parameters are required.  OldFileName is the full filename of the file to be renamed, and NewFileName is the new name for the file.  If wildcards are used with the rename command, they must be used for both OldFileName and NewFileName.

Moving Files - the Move Command
The move command moves one or more files from one virtual directory (technically MoPaQs don't have directories like hard drives do) to another virtual directory. The syntax is as shown:

m[ove] <MPQFile> <SourceFile> <DestinationDirectory>

All parameters are required.  SourceFile is the file(s) to be moved (wildcards allowed), DestinationDirectory is the virtual directory the file(s) to be moved will be placed in.

Deleting Files - the Delete Command
The syntax for the delete file command is:

d[elete] <MPQFile> <FileToDelete>

All parameters are required.  FileToDelete is just that, the file(s) to delete.  Wildcards may be used in FileToDelete.  /r can't be used with this command in WinMPQ.
The first time you use the delete command, you might be rather surprised to find that a deleted file rarely takes up less space in a MoPaQ than a file that hasn't been deleted!  This is due to the fact that the delete command only marks a file as deleted; it doesn't actually remove the file from the archive (to preempt the next question, no, you can't undelete a deleted file).  To actually remove the file from the MoPaQ, you must use the flush command.

Flushing Out an Archive - the Flush Command
The syntax for the flush command is:

f[lush] <MPQFile>

MPQFile is the file to flush.
The flush command searches through a MoPaQ and purges the space deleted files occupy, shrinking the MoPaQ's size if there are any deleted files in it.

Listing the Files in an Archive - the List Command
The syntax for the list files command is:

l[ist] <MPQFile> [Filter] <Out_File>

The parameters in <> are required, ones in [] are optional.  This will list all the files in the MoPaQ to a text file.  The [Filter] parameter is a wildcard filter that specifies what files to list.  The <Out_File> parameter tells WinMPQ the file to write the listing to.

Running Scripts - the Script Command
To run a script:

s[cript] <ScriptFile>

Writing Scripts
A script is basically a file that contains a lot of command lines for WinMPQ to process.  This allows you to compile one or more entire MoPaQs in a single process.

Differences Between the Command Line and Scripts
For simplicity's sake, the command-line and script-line syntax are almost identical.  There are a couple major points of difference, though.

1.	MoPaQs must be explicitly opened in scripts.
2.	Because of this, you don't need to specify which MoPaQ you are working with on every single line, as you did on the command-line.

Opening Archives - the Open Command
The very first thing you must do in scripts is to open the MoPaQ you want to work with.  The general syntax for the 'open archive' command is:

o[pen] <MPQFile> [FileLimit]

Parameters in <> are required, ones in [] are optional. MPQFile is the file to open.  FileLimit only takes affect when the archive is being created from scratch.  It is the maximum number of files that this archive can hold, and is 1024 by default.  If the MoPaQ already exists, FileLimit will have no effect, but no warning will be indicated.  The FileLimit parameter has a minimum value of 16, and a maximum value of 262144.
NOTE: Each file that a MoPaQ can hold (the FileLimit) takes up 16 bytes in the MoPaQ, regardless of whether or not it is used.  This can add up.  For example, an empty MoPaQ with a file limit of 262144 would be 4 MB large!

New Archives - the New Command
The general syntax for the 'new archive' command is:

n[ew] <MPQFile> [FileLimit]

Parameters in <> are required, ones in [] are optional.  MPQFile is the file to open.  This command will force WinMPQ to overwrite the archive and create a new one.

Closing Archives - the Close Command
MPQ2k requires this, but using it in WinMPQ isn't required.  It is very simple to use the close command, as shown on the following line:

c[lose]

Script Comments - the Semicolon ;
On some occasions you may want to put comments in a script file for one reason or another.  To do this, simply put a semicolon(;) as the first character on a line, and the line will be ignored, and no error will be signaled.

Changing the Current Directory - the CD or CHDIR Command
The syntax for this command is:

cd <NewDirectory>

Parameters in <> are required.  NewDirectory is the directory the command will go to.  Use ".." to go to the parent directory.

Changing the Current Drive - the X: Command
The syntax for this command is:

<DriveLetter>:

Parameters in <> are required.  DriveLetter is the letter of the drive you want to switch to.

Closing WinMPQ - the Exit or Quit Command
The syntax for this command is:

x
or
exit
or
quit

This command closes WinMPQ.

The MPQ2k Command Box
This is a text box where you can type in different commands.  The commands are the same as they are in the script files, but there are a few differences.  The Open command can be used to open an archive into the main listing in addition to using the open menu command.  It can also be used by itself to reload an archive.  Just like with scripts, you don't need to specify the name of the archive for commands other than the open command.  All commands typed into the box affect the archive open in the main listing.

Locale ID
The locale ID determines what language version of the software a file is intended for.  Here is a list of some of the ID numbers you can use for files.

0	Language Neutral/English
1031 (407 in hex)	German
1033 (409 in hex)	English (neutral is usually used instead of this)
1034 (40A in hex)	Spanish
1036 (40C in hex)	French
1040 (410 in hex)	Italian
1046 (416 in hex)	Portuguese

Version notes
The menu option for running Mo'PaQ 2000 scripts has support for almost everything.  The /r switch may only be used with Add, and the /lf and /p switches are not used with the List command because WinMPQ does not display the list to the screen.  Scripts can be run within each other in WinMPQ.  Use the /auto parameter with the Add command to use compression auto-selection.

Version history

1.63__________
•	Fixed a bug that caused an overflow error message when opening an archive containing certain numbers of files; especially on Chinese, Japanese, and Korean Windows versions.
•	Added an option to set the block size for new archives.

1.62__________
•	Fixed a bug that prevented extracting empty files.
•	Added an option that would allow one to have WinMPQ search a specified folder and all of its subfolders for file lists with names similar to the open archive.
•	When you add a file, you are prompted for what path to add to the beginning of the filenames, and click cancel, WinMPQ no longer adds the files with no path added but instead it cancels adding the files.

1.61__________
•	WinMPQ was not closing the archive handle properly after adding files that have been modified after being opened from WinMPQ.  This was causing WinMPQ to be unable to open the archive to add files, extract files, etc.  This bug has been fixed in this version.
•	Fixed a bug that caused WinMPQ to be unable to update a file in the archive that has been modified.
•	Mpq Embedder is now included with WinMPQ.  Access it from the "Tools" menu.
•	All options that were available by right-clicking a file are now also available from the "Mpq" menu.
•	The "Tools" menu is now also shown on the right-click context menu shown when right-clicking on a file.
•	The default compression type can be changed now, and the compression level for deflate compression can set.
•	Added a menu command to add a file to the listing if it is not listed and you know the name of the file.
•	Added a menu command to change the locale ID of an existing file.

1.60__________
•	Switched to using SFmpq instead of Mpq Control.
•	Added support for adding files with Warcraft III's new compression method.
•	File encryption can now be enabled or disabled through the "Mpq" menu.

1.54__________
•	Added an option to only use found file lists when using the option to automatically find file lists.
•	Implemented a workaround for the icon color limitation in Visual Basic 4 programs.  Now the icon shown when the program is running is 256 colors as it should be.

1.53__________
•	No longer requires common dialog control.

1.52__________
•	Fixed a bug that would sometimes prevent adding a file if only one was dragged to WinMPQ or only one file was in the folder when using "Add Folder"

1.51__________
•	Files are no longer added twice when dragging them to WinMPQ.
•	Changed compact confirmation message.

1.50__________
•	Fixed an error that would cause WinMPQ to crash if an archive was opened, a file was opened from the archive, and the archive was deleted.

1.49__________
•	Added an option to automatically use file lists with filenames similar to the open mpq archive.

1.48__________
•	Fixed a bug which caused WinMPQ to reload the archive when adding files.
•	The mpq archive listing will now be reloaded if a script is run which modifies the currently open archive.
•	Added Warcraft III maps to open dialog filter.

1.47__________
•	Adding a large number of files to an archive will no longer corrupt the file list in the archive.
•	Script output will now start displaying immediately, rather than after a few lines have executed.

1.46__________
•	Mpq archive loading progress is shown in the status bar now.
•	Mpq archives load quicker.

1.45__________
•	Combined all the options under the options menu into one dialog box with tabs.
•	You may now load multiple file lists through the options menu.
•	When dragging only one file from WinMPQ, the exact filename will always be given to the program you drag the file to, instead of using wildcards.
•	The filenames in the archive listing are now updated when using the rename or delete commands through the mpq2k command box.
•	Added extra names of existing commands.
•	Almost has full support for Mpq2k scripts.

1.42__________
•	Fixed a bug that caused WinMPQ to be unable to create or enumerate registry keys on Windows NT4, 2000, or XP.
•	Fixed some bugs with the popup menu that appears when right-clicking files.
•	WinMPQ now notifies Windows when it associates itself with files, so Windows will update the icon for MPQ archives.
•	Added more checks for whether files exist.  This was done to prevent crashes in some instances.

1.40__________
•	Fixed a division by zero error that would occur when displaying the compression ratio of zero byte files.

1.39__________
•	WinMPQ no longer does checks on open files while the options window is open.  Previously, this caused a message saying "This file is not an MPQ archive." to show when the options window is opened after you've opened files in the MPQ archive.

1.38__________
•	Fixed a bug that caused a "File not found" message when WinMPQ would check the day and time a file was last modified.  This caused WinMPQ to be unable to create new mpq archives.

1.37__________
•	Added a file filter box for making WinMPQ display files with a certain file extension (separate filters with a semicolon ; for multiple filters).
•	Added "Tools" menu for using the open mpq archive or the selected files in a program other than what they are associated with (example:  a hex editor).
•	Made some improvements with the way files are handled when opening a file in an MPQ archive or dragging files from an MPQ archive.
•	Command prompt commands may be typed into the Mpq2k Command box at the bottom of the window.

1.35__________
•	Added a popup-menu that allows you to open a file with a program other than the default.
•	WinMPQ can now be set to open a program other than the default when opening a file from an MPQ archive.
•	When you open a file from an MPQ archive and modify it, WinMPQ will display a prompt asking if you want to add the modified file.
•	Added option to disable loading extra file information.  This can be used to make MPQ archives load faster.

1.33__________
•	Fixed a bug in the code that gets the names of files in a folder and its subfolders.

1.32__________
•	MPQ2k commands can be typed in at a box at the bottom of the WinMPQ window.
•	WinMPQ now uses the startup parameters MPQ2k uses.
•	Added recent file list to file menu.

1.30__________
•	Files can be dragged to WinMPQ to add files and from WinMPQ to extract files.
•	Added compression auto-selection option.
•	Added menu option that adds all the files in a folder and its subfolders.
•	Added menu option to create a file list with the listed filenames in the MPQ archive.
•	Added option to set the folder WinMPQ starts up at.
•	Added option to associate MPQ archives with WinMPQ.
•	The Delete menu option no longer asks if you want to delete a file when none is selected.
•	The Extract menu option will now prompt you for the folder it will extract files to and will also extract all the listed files when none are selected.
•	Added option to suppress prompts.
•	Filenames are shown on the title bar.
•	Added a toolbar.
	
1.20__________
•	Optional parameters in Mo'PaQ 2000 scripts are now optional as they should be.
•	Wildcards and the /r switch work when using the A command in scripts.
•	Scripts are now run in the folder they are located instead of the program's folder.

1.15__________
•	Fixed a bug that prevented WinMPQ from recognizing that audio compression is selected.  Audio compression should work properly now.
•	Added a way to assign a path to files you add without needing to rename them.

1.12__________
•	Fixed a bug that caused embedded mpq archives to be improperly located, causing an overflow when finding the total number of files.

1.11__________
•	Fixed another renaming bug.  It should work properly now.

1.10__________
•	Fixed a bug that prevented the dialog box for adding files to show up on some systems.

1.01__________
•	Fixed a file renaming bug.
•	The method for finding embedded mpq archives is more reliable.

1.00__________
•	Initial release.

Bug Reports

If you find a bug, please send me an e-mail with a description of the error and step-by-step instuctions on how you made it happen.

-ShadowFlare
email:	blakflare@hotmail.com
web page:	http://shadowflare.gameproc.com/