2022年5月11日 星期三

system.loadlibrary JNI_OnLoad Embarcadero.Jni

 https://stackoverflow.com/questions/48670592/invoke-jni-onload-from-delphi

 https://developer.android.com/training/articles/perf-jni

https://community.embarcadero.com/article/technical-articles/1040-using-the-android-jni-bridge-to-open-a-pdf

 Using the Android JNI bridge to open a PDF

Delphi   ZeroPlayer Library  Android dynamic library 

https://docwiki.embarcadero.com/Libraries/Sydney/en/System.IOUtils.TPath.GetLibraryPath

 uses
   ..., Embarcadero.Jni

const
  LIBNAME = 'libtest.so';

function try_load_dll: THandle;
var
  libPath: string;
  OnLoadFunc: TJNI_OnLoad;
  hlib: THandle;
begin
  Result := 0;
  libPath := TPath.Combine(TPath.GetLibraryPath, libname);
  hlib := LoadLibrary(PChar(libPath));
  if hlib = 0 then Exit;
  @OnLoadFunc := GetProcAddress(hlib, 'JNI_OnLoad');
  if not Assigned(OnLoadFunc) then
  begin
    FreeLibrary(hlib);
    Exit;
  end;
  OnLoadFunc(PJavaVM(System.JavaMachine), nil);
  Result := hlib;
end;

https://question-it.com/questions/3417717/vyzov-jni_onload-iz-delphi

LIBNAME = 'libtest.so';
function try_load_dll:integer;
var libPath:system.string;
begin
  _status:= 0 ;
  libPath:=TPath.Combine(tpath.GetLibraryPath,libname);
  _status := LoadLibrary(PChar(libPath));
  result:=_Status;
  if( _status= 0 )then exit;
end;

JNI_OnLoad 


https://coderoad.ru/48670592/%D0%92%D1%8B%D0%B7%D0%B2%D0%B0%D1%82%D1%8C-JNI_OnLoad-%D0%BE%D1%82-Delphi



https://arophix.com/2017/12/01/android-jni/

https://www.programmersought.net/article/329130475.html

https://programmer.ink/think/jni_ndk-advanced-programming-guide-part-2.html

JNI_NDK Advanced Programming Guide Part

沒有留言: