Delphi調用Android的.so文件(轉)


原地址:http://zhidao.baidu.com/link?url=fzqefMM44ljXA5BnAbkX44SapCUteyzlXFvGLKvukBivm9AB-w39P_h7eX1ty-GQX8j3A03AZBPat6yMqjeY4Sc5jlaayMRVOigzCElm_Ky

so本質就是個動態鏈接庫
用gcc編譯就能生成了

Delphi  XE里

if not Tfile.Exists(TPath.GetDocumentsPath+'/libserial_port.so') then
  begin
    showmessage(TPath.GetDocumentsPath+'/libserial_port.so  not found');
  end;
  Handle1:=LoadLibrary(pchar(TPath.GetDocumentsPath+'/libserial_port.so'));//動態裝入庫
if Handle1<>0 then //找到庫
begin
    fun1:=GetProcAddress(Handle1,'openport');
//搜索庫函數Add,並返回函數指針
if Assigned(fun1) then
    begin
......



至於上面的GetDocumentsPath 或者別的目錄也可以 參看TPath的說明和so文件存放目錄有關系

另外值得注意的事傳遞的字符串  xe中是雙字節的。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM