1 message in net.java.dev.jna.usersRe: [jna-users] GetLastError always r...
FromSent OnAttachments
Timothy WallAug 3, 2007 5:35 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] GetLastError always returns zeroActions...
From:Timothy Wall (twal@dev.java.net)
Date:Aug 3, 2007 5:35:00 am
List:net.java.dev.jna.users

There is a test for Kernel32 (com.sun.jna.examples.win32.Kernel32Test) that checks for GetLastError results; you need to make sure that GetLastError is called once before you actually need it, so that the system calls required to set up the calling information don't overwrite the result you're trying to obtain.

It's possible that the VM itself has some effect on GetLastError when making JNI calls, but I don't know of anything specific.

You might try (in your simplified JNI) to determine when the error code gets overwritten. Any Java code that executes in between your failed w32 call and GetLastError has a possibility of invoking some native code that wipes the GetLastError result (I don't recall whether the result is thread-specific or not).

On Aug 3, 2007, at 7:11 AM, Kim Valentine wrote:

Hi, I am trying to use various Kernel32 APIs that signal errors by returning zero or false, but the reason for the failure has to be obtained by calling GetLastError, I mapped that API, but always get zero returned. I suspect that some call required by JNA is calling a windows function that overwrites the lastError. I tried setting up my own JNI dll that only contained a call to GetLastError, but this too always returns zero. Has anyone any ideas how I can get this error code? Rgds Kim

Yahoo! Answers - Get better answers from someone who knows. Try it now.