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!