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


Using the DllImport Custom Attribute



Yüklə 0,84 Mb.
Pdf görüntüsü
səhifə292/294
tarix02.01.2022
ölçüsü0,84 Mb.
#41395
1   ...   286   287   288   289   290   291   292   293   294
DelphiLanguageGuide

Using the DllImport Custom Attribute
You can call unmanaged Win32 APIs (and other unmanaged code) by prefixing the function declaration with the
DllImport
 custom attribute. This attribute resides in the 
System.Runtime.InteropServices
 namespace, as
shown below:
  Program HellowWorld2;
      // Don't forget to include the InteropServices unit when using the DllImport attribute.
      uses System.Runtime.InteropServices;
      [DllImport('user32.dll')]
      function MessageBeep(uType : LongWord) : Boolean; external;
      begin
            MessageBeep(LongWord(-1));
      end.
Note the external keyword is still required, to replace the block in the function declaration. All other attributes, such
as the calling convention, can be passed through the 
DllImport
 custom attribute.

Yüklə 0,84 Mb.

Dostları ilə paylaş:
1   ...   286   287   288   289   290   291   292   293   294




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

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin