lac981
Messages postés14Date d'inscriptionjeudi 14 avril 2011StatutMembreDernière intervention31 mai 2011
-
23 mai 2011 à 16:10
lac981
Messages postés14Date d'inscriptionjeudi 14 avril 2011StatutMembreDernière intervention31 mai 2011
-
31 mai 2011 à 11:11
Bonjour,
Je post ici car j'ai un petit problème avec JNA (Java Native Access), après avoir suivis un tutoriel pour utiliser une librairie je suis arrivé à ces deux fichiers la :
public interface Polar extends Library {
public int fnHRMCom_GetLibraryVersion();
}
la fonction est definit ainsi dans le hrmcom.h :
// Get hrmcom library file version
__declspec (dllexport) int CALLBACK fnHRMCom_GetLibraryVersion (void);
qui est appelé ici:
String message = "La Librairie de Monsieur est chargée ^^";
System.setProperty("jna.library.path", System.getProperty("user.dir") + File.separator + "Library");
final Polar p = (Polar) Native.loadLibrary("hrmcom", Polar.class);
JOptionPane.showMessageDialog(null, message, "Info",
JOptionPane.INFORMATION_MESSAGE);
try
{
p.fnHRMCom_GetLibraryVersion();
} catch (Error e2)
{
int i = 0;
message = e2.getLocalizedMessage()+"\n\n"+e2.getCause()+"\n\n";
for( StackTraceElement st : e2.getStackTrace())
{
if(i> 15)
break;
message+=st.toString()+"\n";
++i;
}
JOptionPane.showMessageDialog(null, message, "Erreur",
JOptionPane.INFORMATION_MESSAGE);
}
return;
la librairie est bien chargé , sauf que lorsque je fait appel a une fonction présente dans la dll, mais j'ai une exception :
Erreur looking up function 'fnHRMCom_GetLibraryVersion' : La procedure spécifiée est introuvable.
Vous pouvez trouvé la dll et le .h à cette adresse.
Si vous avez déjà rencontré le problème ou si vous avez une idée de ce qui a pu se passer, j'attends vos réponses...
lac981
Messages postés14Date d'inscriptionjeudi 14 avril 2011StatutMembreDernière intervention31 mai 20111 31 mai 2011 à 11:11
Map<Object, Object> options = new HashMap<Object, Object>();
options.put(Library.OPTION_FUNCTION_MAPPER, new StdCallFunctionMapper());
final Polar p = (Polar) Native.loadLibrary("hrmcom", Polar.class, options);
System.out.println(p.fnHRMCom_GetLibraryVersion());
import com.sun.jna.win32.StdCallLibrary;
public interface Polar extends StdCallLibrary