HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

SFmpq DLL Help

01-08-2009, 08:28 AM#1
TriggerHappy
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

Expand JASS:

I get the MsgBox("not added"), which means the file hasn't been added to the archive (). Anyways here are all my declarations

Expand JASS:

If anyone is familiar with sfMPQ please help! . I have also found This neat little site.


Notes:
  • I Also have a feeling it has to do with the flags on MpqAddFileToArchive, because i'm using 0 but the documentation has flags like MAFA_COMPRESS, though i have no idea how to use them
01-11-2009, 12:04 AM#2
BlacKDicK
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
TriggerHappy
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
PitzerMike
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 Select

The select case just makes it so that wav files use wave compression and w3m etc. are added uncompressed.