本文介绍了Delphi Prism获得未知标识符“ DllImport”。错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在Delphi Prism中调用Window的SendMessage方法,我声明了以下类:
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;
当我尝试编译时,出现错误 Unknown identifier DllImport
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?
推荐答案
请确保您导入(使用) System.Runtime.InteropServices
。这就是定义DllImport属性的地方。
Make sure you import (use) System.Runtime.InteropServices
. That's where the DllImport attribute is defined.
这篇关于Delphi Prism获得未知标识符“ DllImport”。错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!