在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
Delphi代码 1 unit UnitDll; 2 3 interface 4 5 uses 6 StrUtils, SysUtils, Dialogs; 7 8 function DoBusinessWide(pvData: PWideChar): PWideChar; stdcall; 9 10 implementation 11 12 function DoBusinessWide(pvData: PWideChar): PWideChar; stdcall; 13 var 14 lvData: WideString; 15 begin 16 ShowMessage(pvData); 17 lvData := pvData; 18 ShowMessage(lvData); 19 lvData := lvData + FormatDateTime('YYYYMMDDHHMMSSZZZ',Now); 20 Result := PWideChar(lvData); 21 ShowMessage(Result); 22 end; 23 24 end.
Java调用代码 1 package com.jna.demo; 2 3 import com.sun.jna.Library; 4 import com.sun.jna.Native; 5 import com.sun.jna.WString; 6 7 public class JnaDemo { 8 9 public interface RtcPubLibrary extends Library{ 10 RtcPubLibrary instance = (RtcPubLibrary) Native.loadLibrary("JavaDll", RtcPubLibrary.class); 11 public WString DoBusinessWide(char[] pvData); 12 } 13 14 public static void main(String[] args) { 15 System.setProperty("jna.encoding", "GBK"); 16 StringBuilder sBuilder = new StringBuilder(); 17 sBuilder.append("123测试"); 18 char[] pvData = sBuilder.toString().toCharArray(); 19 WString lvData = RtcPubLibrary.instance.DoBusinessWide(pvData); 20 System.out.println("Wstring-->" + lvData); 21 } 22 23 }
正常返回结果:Wstring-->123测试20160825160441882 |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论