Jump to content

Read MPQ type of file


Recommended Posts

  • Moderators

haijie1223,

Welcome to the Autoit forum. :)

We do not write code to order - rather we help you get your own code working. ;)

What is the C++ code you to which you have (unsuccessfully) linked supposed to do? Perhaps there is something useful already coded in AutoIt. :huh:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

haijie1223,

Welcome to the Autoit forum. :)

We do not write code to order - rather we help you get your own code working. ;)

What is the C++ code you to which you have (unsuccessfully) linked supposed to do? Perhaps there is something useful already coded in AutoIt. :huh:

M23

Thank you

Because my English is very poor, the problem description is not very accurate.

I tried to rewrite by AU3 for a long time, but did not succeed, Can I provide my AU3 code to BBSer help me find where the problem.

Link to comment
Share on other sites

  • Moderators

haijie1223,

Describe the problem in yrou own language and use Google Translate or an equivalent to get it into English. :)

If you have some AutoIt code that illustrates the problem then post it here - but please put [autoit] before and [/autoit] after your posted code so that you get a scrolling box and syntax colouring. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

haijie1223,

Describe the problem in yrou own language and use Google Translate or an equivalent to get it into English. :)

If you have some AutoIt code that illustrates the problem then post it here - but please put

before and
after your posted code so that you get a scrolling box and syntax colouring. ;)

M23

I would like to call the functions in SFmpq.dll file, so go to the official website to find information.Found for some C + + code, and then into the AU3 code, but rewritten for a long time without success. The C + + source code and I wrote it myself AU3 code made ​​up.Please help us to look my code where there are problems.

mpq001.7z

原型.txt

#include <WinAPI.au3>
#include <Array.au3>
;   [url]http://zezula.net/en/mpq/stormlib.html[/url]
;~ Global $dll="Storm.dll"
Global $dll = "SFmpq.dll"
;~ Global $dll = DllOpen(@ScriptDir & "\SFmpq.dll")
;~ Local $handle = DllStructCreate("handle")
Func _WinAPI_SFileOpenArchive($sMpqName, $iPriority, $iFlags, ByRef $hMPQ)
    Local $handle = DllStructCreate("handle")
;~  Local $dll = DllOpen(@ScriptDir & "\SFmpq.dll")
;~  Local $aResult = DllCall($dll, "bool", "SFileOpenArchive", "str", $sMpqName, "dword", $iPriority, "dword", $iFlags, "handle*", 0)
 Local $aResult = DllCall($dll, "bool", "SFileOpenArchive", "str", $sMpqName, "dword", $iPriority, "dword", $iFlags, "handle*", DllStructGetPtr($handle))
 If @error Then Return SetError(@error, @extended, False)
 $hMPQ = $aResult[4]
 Return $aResult[0]
EndFunc   ;==>_WinAPI_SFileOpenArchive
Func _WinAPI_SFileOpenFileEx($hMPQ, $sFileName, $iSearchScope, ByRef $hFile)
;~  Local $aResult = DllCall($dll, "bool", "SFileOpenFileEx", "handle", $hMPQ, "str", $sFileName, "dword", $iSearchScope, "handle*", DllStructGetPtr($handle))
 Local $aResult = DllCall($dll, "bool", "SFileOpenFileEx", "handle", $hMPQ, "str", $sFileName, "dword", $iSearchScope, "handle*", 0)
;~   _ArrayDisplay($aResult)
 If @error Then Return SetError(@error, @extended, False)
 $hFile = $aResult[4]
 Return $aResult[0]
EndFunc   ;==>_WinAPI_SFileOpenFileEx
Func _WinAPI_SFileReadFile($hFile, $pBuffer, $iToRead, ByRef $iRead, $pOverlapped = 0)
 Local $aResult = DllCall($dll, "bool", "SFileReadFile", "handle", $hFile, "ptr", $pBuffer, "dword", $iToRead, "dword*", 0, "ptr", $pOverlapped)
 If @error Then Return SetError(@error, @extended, False)
 $iRead = $aResult[4]
 Return $aResult[0]
EndFunc   ;==>_WinAPI_SFileReadFile
Func _WinAPI_SFileCloseFile($hFile)
 Local $aResult = DllCall($dll, "bool", "SFileCloseFile", "handle", $hFile)
 If @error Then Return SetError(@error, @extended, False)
 Return $aResult[0]
EndFunc   ;==>_WinAPI_SFileCloseFile
Func _WinAPI_SFileCloseArchive($hMPQ)
 Local $aResult = DllCall($dll, "bool", "SFileCloseArchive", "handle", $hMPQ)
 If @error Then Return SetError(@error, @extended, False)
 Return $aResult[0]
EndFunc   ;==>_WinAPI_SFileCloseArchive
Func ExtractFile($sArchiveName, $sArchivedFile, $sFileName)
 Local $hMPQ, $hFile, $handle, $nError = 0
 If $nError = 0 Then
  If Not _WinAPI_SFileOpenArchive($sArchiveName, 0, 0, $hMPQ) Then
   $nError = _WinAPI_GetLastError()
  EndIf
 EndIf
 If $nError = 0 Then
  If Not _WinAPI_SFileOpenFileEx($hMPQ, $sArchivedFile, 0, $hFile) Then
   $nError = _WinAPI_GetLastError()
  EndIf
 EndIf
 If $nError = 0 Then
  $handle = _WinAPI_CreateFile($sFileName, 4)
  If $handle = $INVALID_HANDLE_VALUE Then
   $nError = _WinAPI_GetLastError()
  EndIf
 EndIf
;~ MsgBox(0,"",$nError)
 If $nError = 0 Then
;~   $tBuffer = DllStructCreate("byte[0x10000]")
;~   Dim $tBuffer = 'dword[65536];'
    $tBuffer = DllStructCreate("byte[" & 0x10000 & "]")
  Local $iBytes = 1
  While $iBytes > 0
   _WinAPI_SFileReadFile($hFile, DllStructGetPtr($tBuffer), DllStructGetSize($tBuffer), $iBytes, 0)
   If $iBytes > 0 Then
    _WinAPI_WriteFile($hFile, DllStructGetPtr($tBuffer), DllStructGetSize($tBuffer), $iBytes, 0)
   EndIf
  WEnd
 EndIf
 If $handle <> 0 Then
  _WinAPI_CloseHandle($handle)
 EndIf
 If $hFile <> 0 Then
  _WinAPI_SFileCloseFile($hFile)
 EndIf
 If $hMPQ <> 0 Then
  _WinAPI_SFileCloseArchive($hMPQ)
 EndIf
 Return $nError
EndFunc   ;==>ExtractFile
ExtractFile("kk.mpq", "key.txt", "key.txt")
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...