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