【问题标题】:Undeclared identifier 'GetProcAddress' in a FireMonkey ApplicationFireMonkey 应用程序中未声明的标识符“GetProcAddress”
【发布时间】:2012-03-16 13:59:19
【问题描述】:

我正在尝试通过 Firemonkey 框架使用 Delphi XE2 来制作一个插件系统。问题是我收到错误 GetProcAddress is undeclared identifier。当我尝试在 VCL 项目中使用 GetProcAddress 时,一切正常,那么在谈论 GetProcAddress 以及如何在 Firemonkey 应用程序中使用它时,VCL 和 Firemonkey 有什么区别。

谢谢

【问题讨论】:

    标签: delphi delphi-xe2 firemonkey getprocaddress


    【解决方案1】:

    在为 Windows 编译应用程序时,请使用 Winapi.Windows.GetProcAddress。如果没有,请使用 System.SysUtils.GetProcAddress。在这种情况下,uses 子句应如下所示:

    uses
    {$IFDEF MSWINDOWS}
      Winapi.Windows,
    {$ENDIF}
      System.SysUtils;
    

    【讨论】:

    • +1 不知道 Mac 有相同的过程 :-) 请注意,在 MacOS 中对 GetProcAddress 的实际调用与 Windows 不同,因此您还需要在那里进行定义。
    【解决方案2】:

    GetProcAddress 是一个 Windows API 系统调用。
    因此,它在跨平台 FMX 应用程序中没有位置。

    如果你只希望你的应用在 Windows 上运行,你可以将定义 GetProcAddress 的单位添加到使用子句中。

    发件人:http://docwiki.embarcadero.com/RADStudio/en/Libraries_and_Packages

    Windows 添加到uses 子句中。

    说到GetProcAddress,VCL和Firemonkey有什么区别

    VCL 专门绑定到 Windows,Firemonkey(又名 FMX)是跨平台的,因此不会在其默认使用子句中添加 windows

    【讨论】:

    • docwiki 说有 System.SysUtils.GetProcAddress() (docwiki.embarcadero.com/RADStudio/en/…).. 但我在这里找不到 -> docwiki.embarcadero.com/Libraries/en/System.SysUtils
    • @teran,查看答案中的链接,字面意思是:You can access routines in a library through direct calls to Win32 APIs, including LoadLibrary, FreeLibrary, and GetProcAddress. These functions are declared in Windows.pas. In this case, use procedural-type variables to reference the imported routines.
    • @teran 看起来像是 DocWiki 页面中有关跨平台共享库的文档错误
    • @mjn 无论如何在System.SysUtils 中有一个GetProcAddress 下一条评论:{ GetProcAddress does what it implies. It performs the same function as the like named function under Winapi.Windows. dlsym does not quite have the same sematics as GetProcAddress as it will return the address of a symbol in another module if it was not found in the given HMODULE. This function will verify that the 'Proc' is actually found within the 'Module', and if not returns nil }
    • 所以。对于 Windows,我们必须使用 winapi.windows.getProcAddress,对于 mac - sysUtils.getProcAddress @Stefan Glienke 在他的回答中写道。
    【解决方案3】:

    在 OS X 上,Loadlibray 和 GetProcaddress 函数都没有在 sysutils 中定义 - 这两个函数都专门包含在 POSIX 定义中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多