起步软件技术论坛-X3

 找回密码
 立即注册
搜索
查看: 448|回复: 0

虽然起步在X3这块不再支持,大家有兴趣的话来讨论下平台能否直接调用DLL的问题(尽管官

[复制链接]
发表于 2012-5-8 11:51:14 | 显示全部楼层 |阅读模式
大家都知道平台中不能直接调用外部的DLL,都要通过起步提供的导入工具,按照他们规定的方法导入到平台中。
     在起步提供的帮助文件中发现以下三个函数(平台库---borland---delphi---winodws---Unit即:Borland.Delphi.Windows)。

static function LoadLibrary(lpLibFileName: string): Longword;

static function GetProcAddress(hModule: Longword; lpProcName: string): Business.System.TObject;
  
static function FreeLibrary(hLibModule: Longword): Boolean;

不知道是否有种似曾相识的感觉。。不知道能否直接调用dll。于是做了以下测试。

TGetHostIPs = function(): string of object;

procedure TMainForm.Button14Click(Sender: TObject);
var
  hModule,t: Longword;
  ips:TGetHostIPs;
begin
  hModule:=LoadLibrary('getip.dll');
  if hModule>0 then
  begin
    if GetProcAddress(hModule,'GetHostIP')<> nil then
    begin
      dialogs.ShowMessage('ok');
    end
    else
    begin
      dialogs.ShowMessage('fail');
    end;
  end;
  FreeLibrary(hModule);
end;

     发现输出的结果是ok。说明我们能找到dll中要调用函数的入口地址。现在的问题是怎么根据这个地址去调用函数。
   请各位指教。。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Justep Inc.

GMT+8, 2024-5-4 11:02 , Processed in 0.046344 second(s), 15 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表