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

时间:2010-04-29 22:43:39

标签: 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?,语法看起来一样。是否需要启用设置,或者我是否有语法错误?

1 个答案:

答案 0 :(得分:3)

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