On Jun 8, 2007, at 2:38 PM, Crump, Michael wrote:
Hello,
JNA looks like a great product. I have a single method I need to
call from a windows api so hopefully I will be able to use JNA to
accomplish the task. I've looked at the documentation and the
examples and am still unsure as to how to map this method:
NET_API_STATUS NetUserGetInfo(
LPCWSTR servername,
LPCWSTR username,
DWORD level,
LPBYTE* bufptr
);
Use WString for the first two arguments, and a sufficiently large
array of byte for the buffer. You'll have to look up how big a
NET_API_STATUS is.
The two things I am most unsure of is mapping the return type and
the LPBYTE* which will actually point to a variable sized structure
containing the real result from the method.
Look up the NET_API_STATUS type. However big it is, use the
corresponding Java type for that size.
You need to use PointerByReference to allow the function to "return"
a new pointer. PointerByReference.getValue() will provide you with
the new pointer after the invocation. You can then use
Structure.useMemory to "cast" the pointer to a specific structure
type. Don't forget to free the memory with NetApiBufferFree when
you're done with it.