10 messages in net.java.dev.jna.usersRe: [jna-users] Using custom librarie...
FromSent OnAttachments
Jorge Nieto-MadridJan 7, 2009 4:14 am 
Timothy WallJan 7, 2009 5:38 am 
Jorge Nieto-MadridJan 7, 2009 5:55 am 
Timothy WallJan 7, 2009 7:08 am 
Jorge Nieto-MadridJan 7, 2009 8:04 am 
Timothy WallJan 7, 2009 8:09 am 
Jorge Nieto-MadridJan 7, 2009 8:24 am 
Timothy WallJan 7, 2009 12:15 pm 
Jorge Nieto-MadridJan 8, 2009 6:36 am 
Timothy WallJan 8, 2009 6:47 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] Using custom libraries (dll)Actions...
From:Jorge Nieto-Madrid (jorg@gmail.com)
Date:Jan 7, 2009 8:04:50 am
List:net.java.dev.jna.users

Hi Timothy :-) Thanks again for your response. I am now some steps ahead. now I can connect with the robot.

NativeLibrary.getGlobalVariableAddress(String) provides you with a Pointer, which is the address of the variable. boolean sfIsConnected() { // assumes sfIsConnected is a 32-bit value return Saphira.INSTANCE.getGlobalVariableAddress('sfIsConnected').getInt(0); }

I had to make a small modification to your proposal in order to make it work: --- return (NativeLibrary.getInstance("SF").getGlobalVariableAddress("sfIsConnected").getInt(0))!=0;

My full Saphira code follows:

public interface Saphira extends Library { Saphira INSTANCE = (Saphira)Native.loadLibrary("SF", Saphira.class); // Optional: wraps every call to the native library in a // synchronized block, limiting native calls to one at a time Saphira SYNC_INSTANCE = (Saphira) Native.synchronizedLibrary(INSTANCE);

public static final int SW_SHOWNORMAL = 1; public static final int SW_NORMAL = 1; //....more consts

void sfStartup(HANDLE hInst, int nCmdShow, int async); void sfOnConnectFn(ConnectInterface cI); //Use a non-native function pointer (callback) void sfOnDisconnectFn(ConnectInterface cI); //Use a non-native function pointer (callback) //...More functions

}

What should I change so I can use the instruction you propose? Saphira.INSTANCE.getGlobalVariableAddress('sfIsConnected').get

Instead, do

java -Djna.library.path=c:/saphira/ver62/bin/sh ...

Thanks for the tipp. I am using eclipse, so it is kinda easier now.