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中是双字节的。

posted @ 2015-06-06 14:43  酒醉的Tiger  阅读(3190)  评论(0编辑  收藏  举报