

![]() | 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: |
6 messages in net.java.dev.jna.usersRe: [jna-users] 64bit support and las...| From | Sent On | Attachments |
|---|---|---|
| Daniel Kaufmann | Jun 10, 2007 5:41 pm | |
| Timothy Wall | Jun 10, 2007 6:47 pm | |
| 张久安 | Jun 10, 2007 7:40 pm | |
| Timothy Wall | Jun 10, 2007 8:20 pm | |
| Daniel Kaufmann | Jul 12, 2007 6:20 am | .java |
| Timothy Wall | Jul 12, 2007 8:25 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: | Re: [jna-users] 64bit support and last error windows | Actions... |
|---|---|---|
| From: | Timothy Wall (twal...@dev.java.net) | |
| Date: | Jun 10, 2007 6:47:08 pm | |
| List: | net.java.dev.jna.users | |
On Jun 10, 2007, at 8:41 PM, Daniel Kaufmann wrote:
Hello, I have a couple of doubts and want to check if someone here can help me. I was wandering if it is possible to use the same declaration of a function in 32 bits and 64 bits even that the size of the parameter is variable. For pointers I think I can just use pointers, but if it is an int, that will be 32 bits in a 32 bits platform and 64 bits in a 64 bits platform. In the page I saw "Native long support (32- or 64-bit as appropriate) " but not sure if it is this, or how to use this as couldn't find an example.
Windows native "long" is 32 bits on both platforms. Linux uses different sizes. So for windows, a java int will suffice, while on Linux you would need to use NativeLong.
I also have been calling window api function and I found that I am not able to get the last error code when a function fails , GetLastError() is always returning 0. I am testing in Windows XP professional and sun java 1.5 .0_07. At least it is happening for function CreateProcessA, I think I also got the same behaviour with SetParent function. In VB and in the same happens when you call this kind of function because the code internally might call some other windows function that might set last error to 0, so they provide LastDllError property in Err object to get the last error after calling a native function, instead of GetLastError(). For .Net seem to be the same (need to use SetLastError field in method signature and then use Marshal.GetLastWin32Error ).Is it happening the same here? Is there any way to get the last error?
I haven't had a problem using GetLastError(), although with the current code base you might fail to get the right error the very first time you call it, since the library has to do a function lookup in that case, which probably stomps on the GetLastError value. The function lookup is only done once; the result is cached.
To work around this, you should be able to simply call GetLastError() once, which caches the results of the function lookup, so that the next time it is called there are no intervening API calls between your failing call and the call to GetLastError.
Note that you may need to build from source to get this behavior.








.java