1 message in net.java.dev.jna.usersRe: JNA String as OUT parameter
FromSent OnAttachments
Timothy WallFeb 21, 2008 9:29 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 String as OUT parameterActions...
From:Timothy Wall (twal@dev.java.net)
Date:Feb 21, 2008 9:29:07 am
List:net.java.dev.jna.users

On Feb 21, 2008, at 12:10 PM, graham Allan wrote:

So far I’ve successfully used JNA to access two different DLLs but I’ve run into a problem with a function call that has a string as a parameter.

This is the original call

// numéro de version de l'application / application version number

BOOL GetNumeroVersion(LPSTR szNum);

I’ve translated it to

boolean GetNumeroVersion(String szNum);

But when I call the function while it returns true the string is empty (or unchanged). I’ve tried using an object and a string buffer.

Is there a way of obtaining the modified string?

Use byte[] or Memory. Strings are immutable, and so can't capture changes generated by the native DLL. I don't recall offhand if there's a utility in JNA to get you the zero-terminated byte array, but it's not that hard to do it yourself ("string\0".getBytes()).