2 messages in net.java.dev.jna.usersRe: [jna-users] Need usage info and m...
FromSent OnAttachments
Alan VeaseyApr 29, 2008 9:22 am 
Timothy WallApr 29, 2008 10:10 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: [jna-users] Need usage info and mapping for ReadFileActions...
From:Timothy Wall (twal@dev.java.net)
Date:Apr 29, 2008 10:10:29 am
List:net.java.dev.jna.users

The buffer argument can be of type com.sun.jna.Memory, any Java primitive array type (byte[] would be most obvious), or an NIO buffer.

Easiest is to allocate a chunk of Memory, then extract what you need from it.

On Apr 29, 2008, at 12:23 PM, Alan Veasey wrote:

I am trying to use the ReadFile API function. The signatures goes like this:

BOOL WINAPI ReadFile( __in HANDLE hFile, __out LPVOID lpBuffer, __in DWORD nNumberOfBytesToRead, __out_opt LPDWORD lpNumberOfBytesRead, __inout_opt LPOVERLAPPED lpOverlapped );

So I have made:

boolean ReadFile( HANDLE hFile, Pointer lpBuffer, int nNumberOfBytesToRead, IntByReference lpNumberOfBytesRead, OVERLAPPED lpOverlapped);

I believe this is correct, but is it? I am using HANDLE and OVERLAPPED definitions from the Kernel32 samples.

Now the part I can't figure out - how to use it. I can't instantiate a Pointer or PointerType. So how do I declare the Pointer lpBuffer variable to pass to the function? Also, how do I get the data out of the variable type once read?

Thank you greatly for your help!