| 01-08-2009, 08:28 AM | #1 |
Ok, after hours of research i figured out how to use .dll's and i am having some problems trying to use the functions in the .dll. Whenever I try and add a file to the MPQ with this JASS:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim archiveHandle As IntPtr
Dim archiveName As String = "C:\Users\#\Desktop\Warcraft III\war3.mpq"
If MPQ.SFileOpenArchive(archiveName, 0, 0, archiveHandle) Then
If MPQ.MpqAddFileToArchive(archiveHandle, "C:\Users\#\Desktop\maps.php", "file234928", 0) Then
MsgBox("added")
Else
MsgBox("not added")
MPQ.SFileCloseArchive(archiveHandle)
Me.Close()
End If
MPQ.SFileCloseArchive(archiveHandle)
Else
MessageBox.Show("Unable to open archive")
End If
End Sub
I get the MsgBox("not added"), which means the file hasn't been added to the archive ( ). Anyways here are all my declarations JASS:Imports System.Runtime.InteropServices Friend Class MPQ <DllImport("SFmpq.dll")> _ Public Shared Function SFileOpenArchive(ByVal szMpqName As String, _ ByVal dwPriority As Integer, _ ByVal dwFlags As Integer, _ ByRef phMPQ As IntPtr) As Boolean End Function <DllImport("SFmpq.dll")> _ Public Shared Function SFileCloseArchive(ByVal phMPQ As IntPtr) As Boolean End Function <DllImport("SFmpq.dll")> _ Public Shared Function SFileExtractFile(ByRef hMPQ As IntPtr, _ ByVal filename As String, _ ByVal path As String) As Boolean End Function <DllImport("SFmpq.dll")> _ Public Shared Function SFileCreateArchiveEx(ByVal szMpqName As String, _ ByVal dwCreationDisposition As Integer, _ ByVal dwHashTableSize As Integer, _ ByVal phMPQ As IntPtr) As Boolean End Function <DllImport("SFmpq.dll")> _ Public Shared Function MpqAddFileToArchive(ByVal hMPQ As UInteger, _ ByVal lpSourceFileName As String, _ ByVal szArchivedName As String, _ ByRef dwFlags As Integer) As Boolean End Function <DllImport("SFmpq.dll")> _ Public Shared Function SFileFindFirstFile(ByVal hMPQ As IntPtr, _ ByVal szMask As String, _ ByVal szArchivedName As String, _ ByVal dwFlags As Integer) As Boolean End Function End Class If anyone is familiar with sfMPQ please help! Notes:
|
| 01-11-2009, 12:04 AM | #2 |
I think you need to open the mpq with MpqOpenArchiveForUpdate (or something like that). I can't remember if "SFileOpenArchive" opens the existing mpq with write access. |
| 01-11-2009, 02:19 AM | #3 |
Thanks for an actual reply, even though im sure plenty of members have used this in their tools. I will try it. Thanks. |
| 01-11-2009, 08:16 AM | #4 |
I used something like this in the old VB-days: Code:
HMPQ = MpqOpenArchiveForUpdate(mpqFile, MOAU_OPEN_EXISTING Or MOAU_MAINTAIN_LISTFILE, 1024)
If HMPQ > 0 Then
Select Case Right(importFile, 3)
Case "wav"
result = MpqAddFileToArchiveEx(HMPQ, importFile, targetName, MAFA_REPLACE_EXISTING Or MAFA_COMPRESS, MAFA_COMPRESS_WAVE, Z_DEFAULT_COMPRESSION)
Case "bik", "smk", "w3m", "w3x", "w3n"
result = MpqAddFileToArchiveEx(HMPQ, importFile, targetName, MAFA_REPLACE_EXISTING, 0, 0)
Case Else
result = MpqAddFileToArchiveEx(HMPQ, importFile, targetName, MAFA_REPLACE_EXISTING Or MAFA_COMPRESS, MAFA_COMPRESS_DEFLATE, Z_DEFAULT_COMPRESSION)
End SelectThe select case just makes it so that wav files use wave compression and w3m etc. are added uncompressed. |
