Silently catch windows error popups when calling System.load() in java
Posted
by
Marcelo Morales
on Stack Overflow
See other posts from Stack Overflow
or by Marcelo Morales
Published on 2012-11-05T16:58:35Z
Indexed on
2012/11/05
16:59 UTC
Read the original article
Hit count: 409
I have a Java Swing application, which needs to load some native libraries in windows.
The problem is that the client could have different versions of those libraries. In one recent version, either the names changed or the order on which the libraries must be loaded changed.
To keep up, we iterated over all possible library names but some fail to load (due to it's nonexistence or because another must be loaded previously). This idea works on older Windows but on latter ones it shows a error popup.
I saw on question 4058303 (Silently catch windows error popups when calling LoadLibrary) that I need to call SetErrorMode
but I am not sure how to call SetErrorMode
from jna
. I tried to follow the idea from question 11038595 but I am not sure how to proceed.
public interface CKernel32 extends Kernel32 {
CKernel32 INSTANCE = (CKernel32) Native.loadLibrary("kernel32", CKernel32.class);
// TODO: HELP: HOW define the SetErrorMode function
}
How do I define (from the SetErrorMode documentation):
UINT WINAPI SetErrorMode(
_In_ UINT uMode
);
in the line marked as TODO: HELP:
?
Thanks in advance
© Stack Overflow or respective owner