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

发布于 2024-08-30 19:35:47 字数 561 浏览 11 评论 0原文

我试图在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

墨离汐 2024-09-06 19:35:47

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文