1 message in net.java.dev.jna.usersRe: RE : Re: [jna-users] WIN32_FIND_D...
FromSent OnAttachments
Timothy WallSep 24, 2007 4:30 am 
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:Re: RE : Re: [jna-users] WIN32_FIND_DATA mappingActions...
From:Timothy Wall (twal@dev.java.net)
Date:Sep 24, 2007 4:30:56 am
List:net.java.dev.jna.users

If you have one version that works on XP, and a different version that works on Vista, please post the two versions.

Alternatively, please post the interfaces and/or structures which are working on one but not the other. Unless Microsoft has added a note that a given API works differently between the two OSes, the mappings should be identical (assuming both are 32-bit windows).

On Sep 24, 2007, at 3:38 AM, jean-michel T wrote:

Hi again...

As I told you last time I wrote, my code is compiling and working fine (I'm testing it on windows Vista for the moment).

One of my problems I have right now is that if I try using my code on XP some functions doesn't work anymore and I get some JVM crashes again.

And my Interface i could extend drom StdCallLibrary in windows vista, only seems to work if it extends from LLIbrary in XP.

Is that normal? Are they things I could do in order to have my code work on both OS?

By advance thanks a lot ./

Timothy Wall <twal@dev.java.net> a écrit : On Sep 11, 2007, at 10:42 AM, jean-michel T wrote:

My problem might come from my Structure WIN32_FIND_DATA described on the msdn like the following:

typedef struct _WIN32_FIND_DATA { DWORD dwFileAttributes; FILETIME ftCreationTime; FILETIME ftLastAccessTime; FILETIME ftLastWriteTime; DWORD nFileSizeHigh; DWORD nFileSizeLow; DWORD dwReserved0; DWORD dwReserved1; TCHAR cFileName[MAX_PATH]; TCHAR cAlternateFileName[14]; } WIN32_FIND_DATA, *PWIN32_FIND_DATA, *LPWIN32_FIND_DATA;

What I coded is :

For the Structure: ---- public static class WIN32_FIND_DATA extends Structure {

public int dwFileAttributes; public long ftCreationTime; public long ftLastAccessTime; public long ftLastWriteTime;

Technically, FILETIME is a structure containing two 32-bit values, but this definition should result in the same size/alignment.

public int nFileSizeHigh; public int nFileSizeLow; public int dwReserved0; public int dwReserved1; public String cFileName; public String cAlternateFileName;

These last two are not instances of type "char *", but arrays of TCHAR. While in pointers and arrays are interchangeable as function arguments, they mean different things within a struct definition. "char *" takes up the size of a pointer, while an array of "char" takes up the size of the array. You will need to redefine them as byte[] or char[] (depending on whether you're using ASCII or UNICODE) and initialize them to the proper size, e.g.

public char[] cFileName = new char[MAX_PATH]; public char[] cAlternateFileName = new char[14];

Then you can use Native.toString(char[]) to convert the values back to a Java String.

Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail