

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
4 messages in net.java.dev.jna.users[jna-users] Bad string.| From | Sent On | Attachments |
|---|---|---|
| Johan Lund | May 13, 2009 2:01 am | |
| Timothy Wall | May 13, 2009 3:12 am | |
| Novatchkov Hristo | May 14, 2009 10:05 am | |
| Johan Lund | May 15, 2009 5:09 am |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | [jna-users] Bad string. | Actions... |
|---|---|---|
| From: | Johan Lund (joh...@risken.se) | |
| Date: | May 13, 2009 2:01:16 am | |
| List: | net.java.dev.jna.users | |
Hi friends I've managed to call som functions within a dll, I can readback the results but unfortunately I am not able to call one of the most important functions.
This is how the method looks like: __declspec(dllexport) ADK_ERROR __stdcall AdkOpenEx(CHAR* pszSystemPath, CHAR* pszFtgPath, long lLogOn);
My .h file includes wtypes.h which has this row: typedef char CHAR;
System.setProperty("jna.encoding", "ISO-8859-1"); System.setProperty("jna.library.path","C:\\TEST"); String prg="C:\\TEST\\Common files" String ftg="C:\\TEST\\Mitt företag" NativeLong lLogOn=new NativeLong(1); Map options = new HashMap(); options.put(Library.OPTION_FUNCTION_MAPPER,new com.sun.jna.win32.StdCallFunctionMapper()); Adk adk = (Adk) Native.loadLibrary("Adk", Adk.class,options);
My first approach to a stub was this: public ADK_ERROR AdkOpenEx(String pszSystemPath, String pszFtgPath, NativeLong lLogOn);
My second approach was this: public ADK_ERROR AdkOpenEx(PointerByReference pszSystemPath, PointerByReference pszFtgPath, NativeLong lLogOn);
used like this: Memory prgMemory = new Memory(Native.toCharArray(prg).length); prgMemory.setString(0,prg); PointerByReference prgRef = new PointerByReference(prgMemory); Memory ftgMemory = new Memory(Native.toCharArray(ftg).length); ftgMemory.setString(0,ftg); PointerByReference ftgRef = new PointerByReference(ftgMemory); e=adk.AdkOpenEx(prgRef, ftgRef, lLogOn);
My third approach: public ADK_ERROR AdkOpenEx(java.nio.ByteBuffer pszSystemPath, java.nio.ByteBuffer pszFtgPath, NativeLong lLogOn);
used like this: java.nio.ByteBuffer b1=java.nio.ByteBuffer.allocateDirect(Native.toByteArray(prg).length); b1.put(Native.toByteArray(prg)); java.nio.ByteBuffer b2=java.nio.ByteBuffer.allocateDirect(Native.toByteArray(ftg).length); b2.put(Native.toByteArray(ftg)); e=adk.AdkOpenEx(b1, b2,lLogOn);
My fourth: public ADK_ERROR AdkOpenEx(byte[] pszSystemPath, byte[] pszFtgPath, NativeLong lLogOn);
used like this: e=adk.AdkOpenEx(Native.toByteArray(prg), Native.toByteArray(ftg), 1);
The dll keeps returning an error which states that the path sent to the function is wrong, but it is not wrong. It is the correct path which I try to use but probably the way which I pass it into the function is wrong. Is none of my examples above correct?
Can it be something with encoding, the paths contains Swedish signs?
Is there some way to trace exactly what the the dll recieves when I call it, I've tried a couple of progs but no luck...
I don't know what to do! Please give me a hint, some tip or something cause I'm stuck....







