Difference between revisions of "ReNamer:Scripts:Import DLL"

From den4b Wiki
Jump to navigation Jump to search
(Created page with 'This simple script demonstrates the syntax for importing functions from DLL files. Two functions are imported from a common "kernel32.dll" which exists on all Windows platforms.…')
 
m (Text replacement - "</source>" to "</syntaxhighlight>")
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
{{Go|up=ReNamer:Scripts}}
 +
 
This simple script demonstrates the syntax for importing functions from DLL files.
 
This simple script demonstrates the syntax for importing functions from DLL files.
  
Line 5: Line 7:
 
== Code ==
 
== Code ==
  
<source>
+
<syntaxhighlight lang="pascal">
 
function GetTickCount: Longint;
 
function GetTickCount: Longint;
 
   external 'GetTickCount@kernel32.dll stdcall';
 
   external 'GetTickCount@kernel32.dll stdcall';
Line 16: Line 18:
 
   Sleep(10);
 
   Sleep(10);
 
end.
 
end.
</source>
+
</syntaxhighlight>

Latest revision as of 16:01, 8 February 2017

This simple script demonstrates the syntax for importing functions from DLL files.

Two functions are imported from a common "kernel32.dll" which exists on all Windows platforms. One function which gets the current tick count (number of milliseconds that have elapsed since the system was started) and a simple sleep function.

Code

function GetTickCount: Longint;
  external 'GetTickCount@kernel32.dll stdcall';

procedure Sleep(Milliseconds: Cardinal);
  external 'Sleep@kernel32.dll stdcall';

begin
  FileName := IntToStr(GetTickCount);
  Sleep(10);
end.