Unit unit1; interfaceuses windows, messages, extensions, variants, classes, graphics, controls, forms, dialogs, stdctrls; Type tform1 = Class (tform) button1: tbutton; Procedure button1click (Sender: tobject); Private {private Declarations} public {public declarations} end; var form1: tform1; // declaration of the mb function: function MB (hwnd: hwnd; lptext, lpcaption: pchar; utype: uint): integer; stdcall; implementation {$ R *. DFM} {call functions in external DLL, such as calling messageboxa} // function MB (hwnd: hwnd; lptext, lpcaption: pchar; utype: uint) in system user32.dll: integer; // stdcall; External USER32 name 'messageboxa '; {USER32 is the constant 'user32. dll ', which can be directly written as:} // function MB (hwnd: hwnd; lptext, lpcaption: pchar; utype: uint): integer; // stdcall; External 'user32. DLL 'name' messageboxa '; {name indicates the real name of the function} {external clause indicates that the function is loaded when the unit is loaded, that is, the function is bound early; if the late binding requires the loadlibrary} {stdcall command to indicate that the parameter is passed from right to left (Pascal is the opposite ), data Types that do not pass through the CPU register} {4 parameters can use the corresponding Delphi data type, for example:} // function MB (hwnd: longword; lptext, lpcaption: pchar; utype: longword): integer; // stdcall; External 'user32. DLL 'name' messageboxa '; {or:} // function MB (hwnd: Cardinal; lptext, lpcaption: pchar; utype: Cardinal): integer; // stdcall; external 'user32. DLL 'name' messageboxa '; {if a function is declared in this unit and needs to be called by another unit, declare:} // function MB (hwnd: Cardinal; lptext, lpcaption: pchar; utype: Cardinal): integer; // stdcall; {This example has already been done. If you want to test other cases, you need to comment out} {and then explain the function source in implementation:} function MB; External 'user32. DLL 'name' messageboxa '; // call test: Procedure tform1.button1click (Sender: tobject); var T, B: pchar; begin T: = 'title'; B: = 'content'; MB (0, B, T, 0); end.