Delphi Language Guide Delphi for Microsoft Win32 Delphi for the Microsoft. Net framework


Importing Functions from Libraries



Yüklə 0,84 Mb.
Pdf görüntüsü
səhifə131/294
tarix02.01.2022
ölçüsü0,84 Mb.
#41395
1   ...   127   128   129   130   131   132   133   134   ...   294
DelphiLanguageGuide

Importing Functions from Libraries
To import routines from a dynamically loadable library (.DLL), attach a directive of the form
external
 stringConstant;
to the end of a normal procedure or function header, where stringConstant is the name of the library file in single
quotation marks. For example, on Win32
function SomeFunction(S: string): string; external 'strlib.dll';
imports a function called 
SomeFunction
 from strlib.dll.
You can import a routine under a different name from the one it has in the library. If you do this, specify the original
name in the external directive:
external
 stringConstant1namestringConstant2;
where the first stringConstant gives the name of the library file and the second stringConstant is the routine's original
name.
The following declaration imports a function from user32.dll (part of the Win32 API).
function MessageBox(HWnd: Integer; Text, Caption: PChar; Flags: Integer): Integer; stdcall; 
external 'user32.dll' name 'MessageBoxA';
The function's original name is 
MessageBoxA
, but it is imported as 
MessageBox
.
Instead of a name, you can use a number to identify the routine you want to import:
externalstringConstantindexintegerConstant;
where integerConstant is the routine's index in the export table.
In your importing declaration, be sure to match the exact spelling and case of the routine's name. Later, when you
call the imported routine, the name is case-insensitive.

Yüklə 0,84 Mb.

Dostları ilə paylaş:
1   ...   127   128   129   130   131   132   133   134   ...   294




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin