Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This Nugget is super easy to use and works perfectly. <a href="https://www.nuget.org/packages/UnmanagedExports" rel="nofollow">https://www.nuget.org/packages/UnmanagedExports</a></p> <p>You need Visual Studio 2012 (express). Once installed, just add <code>[RGiesecke.DllExport.DllExport]</code> before any static function you want to export. That's it!</p> <p><strong>Example:</strong></p> <p><strong>C#</strong></p> <pre><code>[RGiesecke.DllExport.DllExport] public static int YourFunction(string data) { /*Your code here*/ return 1; } </code></pre> <p><strong>Java</strong></p> <p>Add the import at the top:</p> <pre><code> import com.sun.jna.Native; </code></pre> <p>Add the interface in your class. Its your C# function name preceded by the letter "I":</p> <pre><code> public interface IYourFunction extends com.sun.jna.Library { public int YourFunction(String tStr); }; </code></pre> <p>Call your DLL where you need it in your class:</p> <pre><code>IYourFunction iYourFunction = (IYourFunction )Native.loadLibrary("full or relative path to DLL withouth the .dll extention", IYourFunction.class);//call JNA System.out.println("Returned: " + IYourFunction.YourFunction("some parameter")); </code></pre> <p>EDIT: If the DLL is 32bit, the JDK/JRE has to be 32bit as well. Add the following check to your code:</p> <pre><code>if(!System.getProperty("os.arch").equals("x86")) { throw new Exception(".NET DLL " + "32bits JRE/JDK is required. Currently using " + System.getProperty("os.arch") + ".\r\nTry changing your PATH environement variable."); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload