简体   繁体   中英

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. Recently I had a question about GetProcessorAffinity and the Delphi declaration was posted as part of the answer. I would like to know how to find that kind of information.

There is no function named GetProcessorAffinity . Probably you mean GetProcessAffinityMask . That function is declared in the RTL unit Winapi.Windows . The source file for this is supplied with Delphi. You can use CTRL + click to navigate to the declaration of any function.

If you do so with GetProcessorAffinity then you will be taken to its implementation in 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 . 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 . 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 . Configure the dialog like this:

在此处输入图片说明

Note that you'll need to use a path suitable to your version of Delphi. For instance, my example is from XE7, which is version 15, but you have XE5 which is version 12.

Delphi comes by default with some Windows API's in different units (a lot of them in the (WinApi.)Windows unit.

A more complete translation of the Windows API headers can be found in the Delphi Jedi Apilib project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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