Delphi's API functions

Posted by John, DelphiLand Team on February 26, 2009

In Reply to API posted by Turboman P16831 on February 25, 2009

: What's the deal with Delphi "API" functions? Can someone please tell me in normal language?

: I'm just a beginner programmer, I use Turbo Delphi Explorer 2006.

The "Windows API" (Windows Application Programming Interface), also called the WinAPI, is a set of routines provided by Microsoft's Windows Operating System, in order to support the building of applications.

The WinAPI is written so that its routines can be called from several programming languages, such as the Delphi programming language, C++ (C Plus Plus), C# (C Sharp), and so on...

The WinAPI gives access to Windows' file system, devices, processes and threads, error handling, registry, GDI (Graphics Device Interface, for outputting graphical content to monitors and printers), creation and management of "windows" and other basic controls (such as buttons, scrollbars,...), handling of mouse and keyboard input,...

Delphi shields you from using the complicated API routines: it translates them into easy-to-use Delphi components, procedures and functions. For starters, you only use this standard Delphi stuff for building applications.

But if you want to do more advanced programming, for which no Delphi components or Delphi routines exist, then you can call most of the Windows API functions. Delphi translates these calls into a syntax that is understood by Windows. The "tranlation" code for this is located in Delphi units such as ShellApi (among others, the very popular ShellExecute and ShellExecuteEx functions), SHLObj, and do on.

Important: this means that:

1. Your application only can use WinAPI stuff that is defined in one of Delphi's units;

2. You have to add these unit(s) to a USES clause in your source code!

Related articles


Follow Ups