Delphi Prism 获取未知标识符“DllImport”错误
我试图在 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;
当我尝试编译时,出现错误 未知标识符“DllImport”
我以此为例、如何在 Delphi Prism 中调用函数 CreateProcess? 和语法看起来是一样的。是否有我需要启用的设置,或者我是否有语法错误?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确保导入(使用)
System.Runtime.InteropServices
。这就是定义 DllImport 属性的地方。Make sure you import (use)
System.Runtime.InteropServices
. That's where the DllImport attribute is defined.