Passing a structur to a DLL ???

BlitzMax Forums/BlitzMax Programming/Passing a structur to a DLL ???

Filax(Posted 2006) [#1]
Hi :) I'm trying to work with UNRAR.DLL but i have problem
to passing structur to a dll function, anybody can help me ?
because i become crazy with bmax incomplete doc ....

Here is the UNRAR SDK :
http://www.blitz3dfr.com/tempo/UnRARDLL.rar

Here is my test :


The UNRAR.H say that :



DStastny(Posted 2006) [#2]
The data structures in the header are not going to be easy to deal with directly from BlitzMax due to the char arrays for the file and archive names. Its possible but it will be a mess.

You will have easier time to create a simple "C" wrapper that can create calls that will interface easier with BMAX over the DLL interface for dealing with the header structure.

Doug Stastny


Filax(Posted 2006) [#3]
Hum its a good idea ! but i'm not a C++ coder :( snif


kfprimm(Posted 2006) [#4]
unrar.bmx


not sure if it works but it did compile and run your example.

to make unrar.a, run this batch file in the folder with unrar.dll. However, you need to have MinGW installed.
pexports unrar.dll >unrar.def
dlltool -d unrar.def -l unrar.a


If still need a C++ wrapper, I'd be happy to write you one.


DStastny(Posted 2006) [#5]
The types wont work, blitzmax does not handle arrays the same way as C/C++

struct Foo {
  char Name[4]
}


in max needs to be like this

Type Foo
  Field Name_1:Byte
  Field Name_2:Byte
  Field Name_3:Byte
  Field Name_4:Byte
End Type


Since this has [1024] size of the names that is a mess. Really needs simple C Callable wrapper passing the names and returning handles to the underlying structures.


Doug Stastny


Gabriel(Posted 2006) [#6]
It definitely needs a wrapper. Unless BRL would like to kindly give us C-Compatible Structs? Pretty please?


Filax(Posted 2006) [#7]
Many thanks for reply guys ! i'll try tomorow :)