Delphi 6之后GetTickCount在哪里?
我正在尝试从 Delphi 6 迁移到 Delphi 2010,但在 Delphi 2010 中找不到 GetTickCount
函数。我有 IdGlobal
、SysUtils
、和我的 use 子句中的 DateUtils
。
var
RefreshTick : Cardinal;
begin
RefreshTick := GetTickCount;
end;
它给了我一个错误:
未声明的标识符:GetTickCount
有什么替代方法?
I am trying to migrate from Delphi 6 to Delphi 2010, but I cannot find the GetTickCount
function in Delphi 2010. I have IdGlobal
, SysUtils
, and DateUtils
in my uses clause.
var
RefreshTick : Cardinal;
begin
RefreshTick := GetTickCount;
end;
It gives me an error:
Undeclared identifier : GetTickCount
What's an alternative to this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
GetTickCount
函数是 Windows 单元的一部分。
The
GetTickCount
function is part of the Windows unit.正如您后来发现的,您使用的
GetTickCount
函数是由 IdGlobal 单元提供的。它与 Windows API 函数同名。 您使用的函数现在名为Ticks
。 将 Windows 添加到您的 use 子句中以获取 API 函数,或者更改您的代码以使用新名称。名称更改似乎是在 2004 年的某个时候发生的。您应该更加努力地使您的 Indy 库保持最新状态。不要只使用 Delphi 附带的版本——在您获得它之前它可能已经过时了。始终从 Indy 的源代码管理下载最新版本。
As you've since discovered, the
GetTickCount
function you were using was provided by the IdGlobal unit. It had the same name as a Windows API function. The function you were using is now namedTicks
. Either add Windows to your uses clause to get the API function, or change your code to use the new name instead.It looks like the name change came sometime in 2004. You should try to be more diligent about keeping your Indy library up to date. Don't just use the version that comes with Delphi — it was probably outdated before you even got it. Always download the latest version from Indy's source control.
GetTickCount
不依赖于 Delphi 的版本,因为它是一个 WinAPI 函数,它也必须存在于 Delphi 2010 中,也存在于 Delphi XE 和 XE2 中。编辑:将 Windows 单元添加到您的使用部分。
GetTickCount
doesn't depend on Delphi's version because it's a WinAPI function and it must be there in Delphi 2010 too, also in Delphi XE and XE2.EDIT: Add Windows unit to your uses section.
在 Lazarus 1.0.12 中,接下来的命令在 Windows 中运行正常:
使用 ...Windows...
这里是代码:
With Lazarus 1.0.12 the next commands worked ok in windows:
Uses ...Windows...
here is the code: