6 messages in net.java.dev.jna.usersRe: [jna-users] Reading string from U...
FromSent OnAttachments
Johan LundMay 15, 2009 6:46 am 
Daniel KaufmannMay 17, 2009 7:22 am 
Johan LundMay 17, 2009 8:19 am 
Johan LundMay 17, 2009 8:22 am 
Daniel KaufmannMay 17, 2009 9:17 am 
Timothy WallMay 17, 2009 9:17 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] Reading string from UnionActions...
From:Daniel Kaufmann (dani@gmail.com)
Date:May 17, 2009 9:17:50 am
List:net.java.dev.jna.users

For checking the size in C use sizeof. Write a small C program that prints sizeof(ADK_DATA) or whatever stucture you want to check. ( if you are using a C compiler instead of C++ it might be sizeof(struct ADK_DATA) ) In java just use size() method of Structure class on a structure instance. They should match. Otherwise there is probably something wrong with your mapping. -Daniel

On Sun, May 17, 2009 at 11:23 AM, Johan Lund <joh@risken.se> wrote:

This is how I read stings and double's might be the problem!!?

public String getAdkStr(AdkLibrary.ADK_DATA adkData, int iFieldId){ if(getAdkType(adkData, iFieldId)==2){ IntByReference iLength=new IntByReference(); AdkGetLength(adkData, iFieldId, iLength); Memory mem = new Memory(iLength.getValue()); PointerByReference pref = new PointerByReference(mem); AdkGetStr(adkData, iFieldId, pref, iLength.getValue()); Pointer p = pref.getValue(); byte[] buffer = p.getByteArray(0, iLength.getValue()); return Native.toString(buffer); }else System.err.println("Wrong fieldtype, tried String."); return null; } public double getAdkDouble(AdkLibrary.ADK_DATA adkData, int iFieldId){ if(getAdkType(adkData, iFieldId)==4){ DoubleBuffer pdValue=DoubleBuffer.allocate(1); AdkGetDouble(adkData, iFieldId, pdValue); return pdValue.get(); }else System.err.println("Wrong fieldtype, tried Double."); return -1; }