Delphi Prism getting Unknown Identifier “DllImport

2019-06-02 14:48发布

I'm trying to call Window's SendMessage method in Delphi Prism, I've declared the class as follow:

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;

When I tried to compile, I get the error Unknown identifier "DllImport"

I used this as an example, How to call function CreateProcess in Delphi Prism? and the syntax looks the same. Is there a setting I need to enable, or do I have a syntax error?

1条回答
Anthone
2楼-- · 2019-06-02 15:24

Make sure you import (use) System.Runtime.InteropServices. That's where the DllImport attribute is defined.

查看更多
登录 后发表回答