6 messages in net.java.dev.jna.usersRe: [jna-users] 64bit support and las...
FromSent OnAttachments
Daniel KaufmannJun 10, 2007 5:41 pm 
Timothy WallJun 10, 2007 6:47 pm 
张久安Jun 10, 2007 7:40 pm 
Timothy WallJun 10, 2007 8:20 pm 
Daniel KaufmannJul 12, 2007 6:20 am.java
Timothy WallJul 12, 2007 8:25 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] 64bit support and last error windowsActions...
From:Timothy Wall (twal@dev.java.net)
Date:Jul 12, 2007 8:25:42 am
List:net.java.dev.jna.users

On Jul 12, 2007, at 9:20 AM, Daniel Kaufmann wrote:

I couldn't test it at this time as I stopped using jna, but I am still unable to get the last error code in windows. Even calling SetLastError and then GetLastError is not working for me. I attach the test I run.

I'm not sure why SetLastError doesn't work, but if you call GetLastError on startup, subsequent calls will work properly. The following code works for me:

kernel.GetLastError(); if (kernel.GetProcessId(null) == 0) { final int INVALID_HANDLE = 6; assertEquals("Wrong error value", INVALID_HANDLE, kernel.GetLastError()); }

I haven't tried in unix doing similar stuff, but my guess is you will have the same kind of problems with errno (I don't know if you can use errno directly in unix, but at least you should be able to use perror to print the error using errno value). It would be nice if jna would provide a way to access this last error codes, with the value immediatly after the call to the native function.

errno is a global variable, not a function, so you wouldn't be able to read it directly from jna unless the system provides a function- call equivalent.