Delphi Prism getting Unknown Identifier “DllImport” error

匆匆过客 提交于 2019-12-10 11:44:35

问题


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:


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



来源:https://stackoverflow.com/questions/2741245/delphi-prism-getting-unknown-identifier-dllimport-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!