Staredit Network

Staredit Network -> Computers and Technical -> MpqCtl.ocx Help?
Report, edit, etc...Posted by O)FaRTy1billion on 2005-10-06 at 00:33:15
I'm trying to use MpqCtl.ocx to extract and add files from MPQs, and it seems to hate me.
I looked through the source code of WinMPQ to see if I could find any help there, but there were too many files and stuff and all I found and tried didn't work. I think there is something I just didn't notice...

Thanks for any help I get..
Report, edit, etc...Posted by LegacyWeapon on 2005-10-06 at 15:03:46
Did you read the Readme that came with MpqCtl.ocx?

Basic loading for scenario.chk and the listfile would look like this:
CODE

Dim mopaq As Long
Dim files() As String

Sub Open
mopaq = mpq.sOpenMpq(FileName)
If mopaq <> "0" Then
   Call Load
   Call ListFiles
   mpq.sCloseMpq mopaq
Else
   MsgBox "This file does not contain an MPQ archive.", vbCritical
End If
End Sub

Sub Load
mpq.sGetFile mopaq, "staredit\scenario.chk", App.path & "\Temp\", False
End Sub

Sub ListFiles
Dim filesbuffer As String

filesbuffer = mpq.sListFiles(mopaq, listfile)
files = Split(filesbuffer, Chr(13) & Chr(10))
End Sub
Report, edit, etc...Posted by O)FaRTy1billion on 2005-10-06 at 18:40:24
The only "readme" I found only had this (and a few things like settings and stuff):
[codebox] For AddFile, AddWavFile, CompactMpq, DelFile, RenFile, FileExists, FileSize, GetFile, GetFileEx, GetFileInfo, GetMpqInfo, and ListFiles, there are versions of them which use an mpq handle instead of a filename.  The names of the functions are mAddFile, mAddWavFile, mCompactMpq, mDelFile, mRenFile, sFileExists, sFileSize, sGetFile, sGetFileEx, sGetFileInfo, sGetMpqInfo, and sListFiles.  Functions with names starting with "m" need a handle from mOpenMpq.  Functions with names starting with "s" need a handle from sOpenMpq.  The handles returned by these two functions are interchangable.

mOpenMpq(mpq filename)
Opens or creates an mpq archive and returns a handle to the mpq.

mCloseMpq(mpq handle)
Closes an archive opened by mOpenMpq.

sOpenMpq(mpq filename)
Opens an mpq archive and returns a handle to the mpq.

sCloseMpq(mpq handle)
Closes an archive opened by sOpenMpq.

AboutBox()
Displays the Mpq Control About Box.

AddFile(mpq, file, mpqpath, compress)
Adds a file to an mpq archive.  Use 1 for compress to compress the file, 0 for uncompressed.

AddWavFile(mpq, file, mpqpath, quality)
Adds a file to an mpq archive with compression for audio files.  Use 0 with quality for
medium quality, 2 for high, and 1 for low.

CompactMpq(mpq)
Removes wasted space in an mpq archive.

DelFile(mpq, file)
Deletes a file from an mpq archive.

FileExists(mpq, file)
Returns true if file exists in mpq.

FileSize(mpq, file)
Returns the size of file.

GetFile(mpq, file, path, usempqpath)
Reads a file from the mpq and saves its contents to a file.  Use false for usempqpath to
extract the file to path.  Use true to extract with the extra path from the file.

GetFileEx(mpq, file, start, length)
Reads a file from the mpq and returns its contents.  Use 0 for start and -1 for length to read
the entire file.

GetFileInfo(mpq, file, infotype)
Gets information about a file in the mpq.
One of these values should be used for infotype:
(4, 8, and 9 are only used when directly accessing lmpqapi)
· 4 Is MPQHANDLE a file or an MPQ?
· 5 Size of MPQ or uncompressed file
· 6 Size of compressed file
· 7 File flags (compressed, etc.)
· 8 Handle of MPQ that file is in
· 9 Position of file pointer in files
Return values for flags:
(These are all in hexadecimal)
· 0x80000000 Exists
· 0x40000000 Unknown
· 0x00020000 ModCryptKey
· 0x00010000 Encrypted
· 0x00000200 Compressed
· 0x00000100 Compressed2
· 0x00000001 Replace existing (This probably isn't ever used)

GetMpqInfo(mpq, infotype)
Gets information about the mpq.
One of these values should be used for infotype:
(4 is only used when directly accessing lmpqapi)
1 Block size in MPQ
2 Hash table size in MPQ
3 Number of files in MPQ
4 Is MPQHANDLE a file or an MPQ?
5 Size of MPQ or uncompressed file

GetTitle()
Returns the title message.

HideTitle()
This prevents Mpq Control from returning the title message to the GotMessage event.  This
was kept for compatibility with previous versions.

LastError()
Returns the code of the last error.
Error codes:
(hexadecimal)
· 0x85000001 Unspecified error
· 0x85000002 Can't find StarEdit.exe
· 0x85000003 Bad version of StarEdit.exe.  Need SC/BW 1.07
· 0x85000004 StarEdit.exe is running.  Must be closed

ListFiles(mpq, filelist)
Returns a list of files in mpq from (listfile).  You can specify an external list with filelist.  You may use multiple list files by separating them with a new line character.

MpqInitialize()
Initializes lmpqapi.dll and returns true if it is successful.  Returns true every subsequent time
it is called after a successful initialization.

RenFile(mpq, oldfilename, newfilename)
Changes the name of a file in the mpq.

SetDefaultMaxFiles(maxfiles)
Same as the DefaultMaxFiles property.  This was kept for compatibility with previous versions.

SetLocale(newlocaleid)
Setting this will cause the Mpq Control to read files with the language code specified.

ShowTitle()
This causes Mpq Control to return the title message to the GotMessage event before the
other messages.  This is the default.  This was kept for compatibility with previous versions.[/codebox]

And thanks for the help. (I was even thinking about PMing you instead of making a topic, since you seem to know everything about it)

ADDITION:
I get an error..
QUOTE
Scripting runtime error '424'
Object required: 'mpq'.
Report, edit, etc...Posted by LegacyWeapon on 2005-10-06 at 19:09:49
You need to add the MpqControl to the form or whatever. I renamed mine "mpq" because the default is "MpqControl1"
Report, edit, etc...Posted by O)FaRTy1billion on 2005-10-06 at 20:07:54
QUOTE
Scripting runtime error '424'
Object required: 'MpqControl1'.


QUOTE(LegacyWeapon @ Oct 6 2005, 05:09 PM)
You need to add the MpqControl to the form or whatever.

How would I do that? *O)FaRTy1billion is nub ermm.gif
Report, edit, etc...Posted by LegacyWeapon on 2005-10-06 at 21:31:04
Ah so you don't know how to use components yet...
http://www.vbtutor.net/vbtutor.htm

Lessons 15-19 talk about components (mainly 15) and making a music player.
Report, edit, etc...Posted by O)FaRTy1billion on 2005-10-07 at 15:24:43
Ive made music scripts for StealthBot with VBS_APIs.ocx to play music...

uhh... Is there any way to add the compenent by typing something in? (I don't have Visual Studios or whatever; can't use on winME.. need XP or 2000 I think)
Try adding a component, saving the thing, and then opening the files with Notepad...??
Report, edit, etc...Posted by LegacyWeapon on 2005-10-07 at 15:43:02
I have no clue how to add components or use them in VBS.

Here you can read about VBS that might have something to do with ActiveX components or whatnot.
http://msdn.microsoft.com/library/default....oriVBScript.asp

I'm sure you could just download and use VB Express:
http://msdn.microsoft.com/VBasic/Express/

Edit: I found this line in my main.frm when viewing in Notepad:
CODE
Object = "{DA729162-C84F-11D4-A9EA-00A0C9199875}#1.60#0"; "MpqCtl.ocx"
Report, edit, etc...Posted by O)FaRTy1billion on 2005-10-07 at 15:57:22
biggrin.gif That is what I needed probably. I will try it.

Was there anything else that had to do with it?

ADDITION:
QUOTE(LegacyWeapon @ Oct 7 2005, 01:43 PM)
I'm sure you could just download and use VB Express:
http://msdn.microsoft.com/VBasic/Express/
Nope. Same error as anything else...
QUOTE
This product cannot be installed on Microsoft Windows ME, Windows NT 4.0, or earlier. You must upgrade your operating system to Windows 2000 or later before installing this product.
Report, edit, etc...Posted by LegacyWeapon on 2005-10-07 at 17:09:09
There was a bit of stuff about the location of it on the form and the name of it...
CODE
  Begin MPQCONTROLLib.MpqControl mpq
     Left            =   3120
     Top             =   0
     _Version        =   65542
     _ExtentX        =   873
     _ExtentY        =   873
     _StockProps     =   0
  End
Report, edit, etc...Posted by O)FaRTy1billion on 2005-10-07 at 17:49:37
I guess I have to wait till I get a new computer cry.gif
Report, edit, etc...Posted by LegacyWeapon on 2005-10-07 at 19:37:44
Or just a new OS (Operating System).
Report, edit, etc...Posted by O)FaRTy1billion on 2005-10-08 at 21:49:35
Not worth buying an OS for this comp, its Pentium 2, 192mb RAM, and as old as your mother.

ADDITION:
Maybe set the components and save it, and instead of just looking for a line, copy all the files and send them to me?
Then I could just add all the scripting and stuff to that and see what happens... Or we could do what I previously suggested... (wait till I get a new computer)
Next Page (1)