Openkore.com

OpenKore Forums
It is currently 24 Apr 2014, 10:18

All times are UTC - 5 hours [ DST ]





Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: GRFTool (grf.dll -> vb.net)
PostPosted: 27 Jun 2008, 08:11 
Offline
Noob
Noob

Joined: 14 Apr 2008, 04:46
Posts: 10
Hi,

anyone got a small tutorial how to use the grf.dll in vb.net?

Code:
    ' GRF Types
    Enum GrfErrorType
        GE_SUCCESS
        GE_BADARGS
        GE_INVALID
        GE_CORRUPTED
        GE_NSUP
        GE_NOTFOUND
        GE_INDEX
        GE_ERRNO
        GE_ZLIB
        GE_ZLIBFILE
        GE_NODATA
        GE_BADMODE
        GE_NOTIMPLEMENTED
    End Enum

    Public Structure GrfError
        Dim type As GrfErrorType
        Dim line As Integer
        Dim name As String
        Dim func As String
        Dim extra As Int64
    End Structure

    Public Structure GrfFile
        Dim compressed_len_aligned As Integer
        Dim compressed_len As Integer
        Dim real_len As Integer
        Dim flags As Int16
        Dim hash As Integer
        Dim name As String
        Dim data As String
    End Structure

    Public Structure Grf
        Dim filename As String
        Dim len As Integer
        Dim type As Integer
        Dim version As Integer
        Dim nfiles As Integer
        Dim files() As GrfFile
        Dim first As GrfFile
        Dim last As GrfFile

        Dim allowCrypt As Int16
        Dim f As System.IO.File
        Dim allowWrite As Int16
        Dim zbuf As Object ' void
    End Structure

    Public Structure GrfOpenCallback
        Dim file As GrfFile
        Dim mError As GrfError
    End Structure

    ' GRF Library (grf.dll) functions
    Public Declare Function GrfOpen Lib "grf.dll" Alias "grf_open" (ByVal fname As String, ByVal mode As String, ByVal mError As GrfError, ByVal callback As GrfOpenCallback) As Grf
    'Public Declare Function GrfOpen Lib "grf.dll" Alias "grf_open_callback" (ByVal fname As String, ByVal mode As String, ByVal mError As GrfError, ByVal callback As IntPtr) As Grf
    Public Declare Function GrfExtract Lib "grf.dll" Alias "grf_extract" (ByVal grf As Grf, ByVal grfname As String, ByVal file As String, ByVal mError As GrfError) As Integer
    Public Declare Function GrfClose Lib "grf.dll" Alias "grf_close" (ByVal grf As Grf)
    Public Declare Function GrfFree Lib "grf.dll" Alias "grf_free" (ByVal grf As Grf)

Sub Main()
        Try
            Dim myGrf As Grf
            Dim err As GrfError
            Dim cb As GrfOpenCallback
            myGrf = GrfOpen("data.gpf", "rb", err, cb)
        Catch ex As Exception
            Console.WriteLine(ex.ToString)
        End Try
    End Sub


Which one to use? grf_open or grf_open_callback?
Getting an error:
Code:
Method's type signature is not PInvoke compatible.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
[ Time : 0.045s | 14 Queries | GZIP : On ]