-
-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to Call JNA to VB.net ByRef String Function #25
Comments
:) You should use pointer to allocated string. For example: [DllExport]
public static int getStringArgs(ref IntPtr ptr)
{
ptr = new UnmanagedString("Hello from .NET and Conari", UnmanagedString.SType.Ansi);
return 0;
}
[DllExport]
public static IntPtr getString()
{
return new UnmanagedString("Hello from .NET and Conari", UnmanagedString.SType.Ansi);
} Java: public interface CAPI extends Library
{
public PointerByReference getString();
public int getStringArgs(LongByReference ptr); // see also Pointer etc.
} CAPI l = Native.loadLibrary("DllExportAndJNA", CAPI.class);
...
LongByReference ptr = new LongByReference();
l.getStringArgs(ptr);
(new Pointer(ptr.getValue())).getString(0); // Hello from .NET and Conari PointerByReference pbr = l.getString();
pbr.getPointer().getString(0); // Hello from .NET and Conari etc. anyway, do not forget deallocate all data from unmanaged memory ! |
Thank you very much 3F. Here is my vb code.
Thank you for your help. |
* FIXED: Fixed bug when some methods cannot be exported. Issue #59. * FIXED: Bug 'The node is not parented by this object' when Configuring projects. Issue: #77. * FIXED: Fixed GDI objects leak in Wizard. * FIXED: `-msb` key cannot affect for GetNuTool section. Issue #74. * FIXED: Bug when automatic restoring still uses default keys from manager after configuring with custom `-server`. * FIXED: Problem with double quotes for `-packages` key. * FIXED: Possible incorrect repetition of the relative path for `-packages` key. * FIXED: Possible problem 'The request was aborted: Could not create SSL/TLS secure channel.'. Issue: #77. * FIXED: Possible problem with path when `-msb` key contains round brackets, e.g.: `D:\C\Program Files (x86)\Microsoft Visual Studio\`... * NEW: Implemented features for additional automation. Issue #76. New actions: * `-action Export` * `-action Recover` * `-action Unset` Documentation: https://github.com/3F/DllExport/wiki/DllExport-Manager#automation * NEW: Added proxy support for manager. The common format: `[usr[:pwd]@]host[:port]` Documentation: https://github.com/3F/DllExport/wiki/DllExport-Manager#proxy * NEW: Wizard. Added sorting an projects in main window by its installing status and by availability. * NEW: Wizard. Added filter for list of projects in main wizard window. * NEW: New 'Offline' versions from our packages. See GitHub Releases page. * NEW: Added key to force update `Reference` without PublicKeyToken. Issue #65. * NEW: Added `-force` key for manager to use aggressive behavior, e.g. like removing pkg when updating. Wiki: https://github.com/3F/DllExport/wiki/DllExport-Manager#receiving-new-package-version * NEW: New action `-action Upgrade`. Aggregates an Update action with additions for upgrading. Today's an Upgrade action: ``` DllExport -action Upgrade ... ``` is equal to: ``` DllExport -action Update -mgr-up -force ... ``` Wiki: https://github.com/3F/DllExport/wiki/DllExport-Manager#updating * CHANGED: Case sensitivity for the Action names. * CHANGED: `-action Default` for nothing. * CHANGED: UI layout fixes for -Info form (Thanks @Genteure, Issue #61). * CHANGED: Allows absolute path for `-packages` key. * CHANGED: `-sln-file` key now can affect to `-action Configure` * CHANGED: hMSBuild tool now is also distributed inside root directory of the packages zip & nupkg. Use this for EXP0014 problem: "RunIlAsm. The library manager still cannot be found." Example: https://www.youtube.com/watch?v=zUejJ4vUPGw * CHANGED: Updated GetNuTool v1.6.2 * CHANGED: Updated MvsSln v2.1.0 * OTHER: Some other fixes and changes with manager and wizard. * NOTE: To upgrade configured version: `DllExport -action Upgrade ...` * NOTE: Configuring projects: `DllExport -action Configure ...` * NOTE: Screencasts: * Quick start: https://www.youtube.com/watch?v=sBWt-KdQtoc * Basic examples for C++ and C#: https://www.youtube.com/watch?v=9Hyg3_WE9Ks * Complex types and Strings: https://www.youtube.com/watch?v=QXMj9-8XJnY * NOTE: Our actual wiki - https://github.com/3F/DllExport/wiki * Documentation for manager: https://github.com/3F/DllExport/wiki/DllExport-Manager
I want to call vb.net ByRef and String function from java.
vb.net dll is maked by UnmanagedExports.
//java
String[] str = {"testJavaWrited"};
String[] str2 = {"testJavaWrited2"};
final VbWrapper wr = (VbWrapper)Native.loadLibrary("vbtestlib", VbWrapper.class);
wr.test(str,str2);
System.out.println(str); // not printed
System.out.println(str2); // not printed
// jna mapping
public interface VbWrapper extends Library {
public int test(String[] str,String[] str2);
}
//vb.net
<DllExport("test", CallingConvention.StdCall)>
Function test(ByRef str As String, ByRef str2 As String) As Integer
MsgBox("test Called") ' printed
MsgBox(str) ' printed
str = "testStringWrited"
str2 = "testStringWrited2"
Return 0
End Function ' heap error
I need your help everybody.
http://stackoverflow.com/questions/41830352/how-to-call-jna-to-vb-net-byref-string-function
The text was updated successfully, but these errors were encountered: