delphi - Delphi Prism获取未知标识符“DllImport”错误

标签 delphi delphi-prism oxygene

我试图在Delphi Prism中调用Window的SendMessage方法,我声明了以下类:

type
  MyUtils = public static class
  private
    [DllImport("user32.dll", CharSet := CharSet.Auto)]
    method SendMessage(hWnd:IntPtr; Msg:UInt32; wParam:IntPtr; lParam:IntPtr):IntPtr; external;
  protected
  public
  end;


尝试编译时,出现错误Unknown identifier "DllImport"

我以这个为例,How to call function CreateProcess in Delphi Prism?和语法看起来相同。有需要启用的设置,还是语法错误?

最佳答案

确保导入(使用)System.Runtime.InteropServices。这就是定义DllImport属性的地方。

关于delphi - Delphi Prism获取未知标识符“DllImport”错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2741245/

相关文章:

xml - 如何使用XML/SGML实体将UTF-16转换为ASCII/ANSI?

.net - 将 MbUnit 与 Delphi Prism 结合使用

c# - 如何在 Delphi 中使用非托管导出

winforms - 为什么对话结果为零?

delphi - 符号 'Resume' 已弃用/线程错误 : The handle is invalid (6)

delphi - 将 WSDL 导入 Delphi 7 时出现堆栈溢出错误

windows - Delphi XE2中如何确定已注册OCX的版本号

.net - 为什么VCL/RTL中有这么多$IF DEFINED(CLR)?

delphi - 什么是Delphi Prism LineFeed

visual-studio - VS 2008 插件 - 具有结构突出显示 - 支持语法 Delphi Prism