/* run-time loading of a 3rd party DLL M. Gallant 01/16/2002 */ public class dynaLoad { public static void main (String args[]) { final int BUFFSZ = 3000 ; StringBuffer buffer = new StringBuffer( BUFFSZ) ; int hmod = LoadLibrary("MIGUTILSLIB"); int funcaddr = GetProcAddress(hmod, "GetAllEnvars"); int result = call(funcaddr, buffer, BUFFSZ+1 ); //call() function declaration must match parameter list. FreeLibrary(hmod); System.out.println("Result of functdion call: \n" + buffer.toString() + " \n Characters: " + result) ; } /** @dll.import("KERNEL32",auto) */ public native static int LoadLibrary(String lpLibFileName); /** @dll.import("KERNEL32",auto) */ public native static boolean FreeLibrary(int hLibModule); /** @dll.import("KERNEL32",ansi) */ public native static int GetProcAddress(int hModule, String lpProcName); /** @dll.import("msjava") */ static native int call(int funcptr, StringBuffer envars, int buffsize); }