3 messages in net.java.dev.jna.usersHelp with mapping a dll library
FromSent OnAttachments
Jan FinisMar 21, 2008 12:49 pm 
Timothy WallMar 21, 2008 1:54 pm 
Jan FinisMar 21, 2008 2:35 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Help with mapping a dll libraryActions...
From:Jan Finis (jan_@gmx.de)
Date:Mar 21, 2008 12:49:35 pm
List:net.java.dev.jna.users

Hi,

I am trying to map a dll library to java. I have tested some functions, they work properly. But one function doesn't and I am unable to get it to work.

C-Declaration in header file:

#ifdef SFMPQAPI_EXPORTS #define SFMPQAPI __declspec(dllexport) #else #define SFMPQAPI __declspec(dllimport) #endif

typedef HANDLE MPQHANDLE; BOOL SFMPQAPI WINAPI SFileOpenArchive(LPCSTR lpFileName, DWORD dwPriority, DWORD dwFlags, MPQHANDLE *hMPQ);

it opens an archive file and puts it into the hMPQ handle. It returns its success.

Proper use in c:

HANDLE hMpq = NULL; const char *name = "test.w3x"; int success = SFileOpenArchive(name, 0, 0, &hMpq)

it is always successful i.e. success = true using it under java it always fails (success = false). I am currently using this declaration:

boolean SFileOpenArchive(String lpFileName, long dwPriority, long dwFlags, PointerByReference hMPQ);

and use it like this:

PointerByReference pref = new PointerByReference(); boolean b = CLibrary.INSTANCE.SFileOpenArchive("test.w3x",0,0, pref); System.out.println(b);

b is always false, i.e. the function failed.

what do I do wrong? I think it is something with the by-reference call of hMPQ.

Thanks for help.