简体   繁体   English

在哪里可以找到Windows API调用的Delphi声明?

[英]Where can I find Delphi Declarations for Windows API calls?

I want to be able to see how one calls the Windows API in Delphi. 我希望能够看到人们如何在Delphi中调用Windows API。 Recently I had a question about GetProcessorAffinity and the Delphi declaration was posted as part of the answer. 最近,我有一个关于GetProcessorAffinity的问题,Delphi声明已发布为答案的一部分。 I would like to know how to find that kind of information. 我想知道如何找到这种信息。

There is no function named GetProcessorAffinity . 没有名为GetProcessorAffinity函数。 Probably you mean GetProcessAffinityMask . 可能您是说GetProcessAffinityMask That function is declared in the RTL unit Winapi.Windows . 该函数在RTL单元Winapi.Windows The source file for this is supplied with Delphi. 此源文件随Delphi提供。 You can use CTRL + click to navigate to the declaration of any function. 您可以使用CTRL +单击导航到任何函数的声明。

If you do so with GetProcessorAffinity then you will be taken to its implementation in Winapi.Windows . 如果使用GetProcessorAffinity这样做,那么您将被带到Winapi.Windows实现。 Now, that implementation looks like this: 现在,该实现如下所示:

function GetProcessAffinityMask; external kernel32 name 'GetProcessAffinityMask';

This is not terribly useful, but the information you are looking for is close by. 这不是非常有用,但是您正在寻找的信息就在附近。 Now that you are in the file which contains the implementation, you can find the declaration. 现在您已经在包含实现的文件中,您可以找到声明。 Move to the top of the file and search for GetProcessAffinityMask . 移至文件顶部,然后搜索GetProcessAffinityMask That will take you here: 那将带您到这里:

function GetProcessAffinityMask(hProcess: THandle;
  var lpProcessAffinityMask, lpSystemAffinityMask: DWORD_PTR): BOOL; stdcall;

That's the information that you need. 这就是您需要的信息。

Many of the Windows API functions, but not all, are declared in Winapi.Windows . Winapi.Windows中声明了许多Windows API函数,但不是全部。 But the process described above will take you to the right file in any case. 但是无论如何,上述过程将带您进入正确的文件。

The other technique that is useful is to search within files. 另一个有用的技术是在文件中搜索。 From the IDE Search menu select Find in Files . 从“ IDE 搜索”菜单中,选择“在文件中查找” Configure the dialog like this: 像这样配置对话框:

在此处输入图片说明

Note that you'll need to use a path suitable to your version of Delphi. 请注意,您需要使用适合您的Delphi版本的路径。 For instance, my example is from XE7, which is version 15, but you have XE5 which is version 12. 例如,我的示例来自版本15的XE7,但是您拥有版本12的XE5。

Delphi comes by default with some Windows API's in different units (a lot of them in the (WinApi.)Windows unit. 默认情况下,Delphi带有一些Windows API,它们以不同的单位(很多都在(WinApi。)Windows单位中)提供。

A more complete translation of the Windows API headers can be found in the Delphi Jedi Apilib project. Windows API标头的更完整翻译可以在Delphi Jedi Apilib项目中找到。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM