为此我需要什么单位范围?

发布于 2025-01-05 02:58:53 字数 778 浏览 2 评论 0原文

我正在尝试安装第 3 方软件包,但出现编译错误:

[DCC Error] fiile/line : E2003 Undeclared identifier: 'Windows'

它指的是这一行:

wnd := Windows.GetFocus;

似乎很明显我没有正确的单位范围 - 但我需要哪个(以及是否有通用方法找到我需要的 use 子句)?

我目前

Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;System;Xml;Data;Datasnap;Web;
Soap;Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;Winapi;System.Win

[更新]

interface
uses
SysUtils, winapi.windows, Classes, Controls, ExtCtrls, Graphics, StdCtrls, 
Dialogs, IniFiles, winapi.messages, Forms, Math
{$IFDEF DELPHI6_LVL}
, Variants
{$ENDIF}
;

在实施部分没有使用

。 [更新] 我忘了提及。我无法(以同样的方式)将其安装在一台笔记本电脑上。然后我第二次就成功了。问题是我宁愿把它放在桌面上,但在全新安装 XE2 starter 后我遇到了这些问题。

I am trying to install a 3rd party package and I get a compile error:

[DCC Error] fiile/line : E2003 Undeclared identifier: 'Windows'

which refers to this line:

wnd := Windows.GetFocus;

It seems fairly obvious that I don't have my Unit Scopes right - but which do I need (and is there a general approach to find which use clause I need)?

I currently have

Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;System;Xml;Data;Datasnap;Web;
Soap;Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;Winapi;System.Win

[Update]

interface
uses
SysUtils, winapi.windows, Classes, Controls, ExtCtrls, Graphics, StdCtrls, 
Dialogs, IniFiles, winapi.messages, Forms, Math
{$IFDEF DELPHI6_LVL}
, Variants
{$ENDIF}
;

No uses in the impementation section.

[Upate]
I forgot to mention. I failed (in the same way) to install it on one laptop. Then I succeeded on a second. The trouble is that I'd rather have it on my desktop and after a fresh install of XE2 starter I get these problems.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

听风念你 2025-01-12 02:58:53

假设您的用户完全命名了 Windows 单元,则似乎是通过将该单元命名为 Winapi.Windows 来实现的。因此,您的代码也必须这样做,并编写为

wnd := Winapi.Windows.GetFocus;

当您通过命名完全作用域的单元名称来使用单元时,您还必须在该单元的后续代码中使用完全作用域的名称。

现在,如果您想使用名称 Windows,则必须在使用子句中将单元命名为 Windows,并让单元别名设置完成其工作。如果您通过将其命名为 Windows 来导入该单元,那么您的原始代码将起作用。

非常清楚的

uses
  Winapi.Windows;

是:您现在拥有但您需要:

uses
  Windows;

用于编译代码。

Assuming that your uses names the Windows unit at all, it would appear to do so by naming the unit as Winapi.Windows. And so your code must also do so and be written as

wnd := Winapi.Windows.GetFocus;

When you use a unit by naming the fully scoped unit name, you must also use the fully scoped name in subsequent code in that unit.

Now, if you want to use the name Windows then you must name the unit as Windows in the uses clause and let the unit alias setting do its job. If you imported the unit by naming it Windows then your original code will work.

To be very clear:

uses
  Winapi.Windows;

is what you have now but you would need:

uses
  Windows;

for your code to compile.

泪之魂 2025-01-12 02:58:53

您的单位范围看起来不错,因此请尝试在您的 uses 部分中声明这两个选项

Windows 而不是 Winapi.Windows

或像这样修改您的代码

wnd :=  Winapi.Windows.GetFocus;

You unit scope looks fine, so try these two options

declare in your uses section Windows instead of Winapi.Windows

or modify your code like so

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