dll[-] dllfile [functype]Function [arguments]
dll[-] dllfile (tab) [functype]Function1 [arguments] [(tab) [functype]Function2 [arguments] ...]
Use this syntax to declare different name (alias) than it is in dll:
dll dllfile [TrueName][functype]AnyName [arguments]
Use this syntax to retrieve the function by its ordinal number:
dll dllfile [ordinal][functype]AnyName [arguments]
dllfile - dll filename or full path. Can be enclosed in quotes or not. Named constants can be used, but only that begin with _DLL_ (QM 2.2.0).
functype - function's return type. If omitted, the return value is undefined (void).
Function - function's name.
arguments - list of arguments. Syntax for single argument: [argtype]argname . If argument type is int, argtype can be omitted.
Options: - delay-loading (QM 2.1.9).
Declares a dll function.
By default, loads the dll and finds the function when compiling (in exe - when starting the program). If the dll or the function is not found, generates error (in exe - the exe ends with an error message). If dll- is used, the dll and function will be loaded at run time, when needed (called, address queried, etc). If the dll or function is not found at run time, generates error that can be handled by err.
Some functions in dll have two versions: with 'A' and with 'W' suffix. The A version uses ANSI text. The W version uses Unicode UTF-16 text. You can omit 'A' suffix. If QM does not find the specified function, it searches for function with 'A' suffix. To support Unicode, use functions with 'W' suffix. Example.
Supported are __stdcall and __cdecl calling conventions.
QM 2.2.1: Can be used optional arguments. They are declared by enclosing into [ ]. Must not be followed by required arguments. When calling the function, optional arguments can be omitted. The default value is 0. User-defined types passed by value cannot be optional.
QM 2.2.1: To declare variable number of arguments, add space and ... at the end. Types of unspecified arguments cannot be converted, therefore must match expected.
Allowed is function declaration without arguments. When calling such function, can be specified any number of arguments. Argument types must match expected.
Dll functions also can be declared in reference files and type libraries, which allows you to use them without declaring explicitly. Many declarations are in WINAPI and WINAPIV reference files. Usage example:
int hdc=WINAPI.CreateCompatibleDC(0)
Some Windows functions are declared by default, in the System\Declarations folder.
Usually you don't use full path in dllfile. Then the dll file should be in QM folder or in System32 folder. If used in exe, it should be in exe folder (however, when building the exe, it also must be in QM folder) or in System32 folder.
See also: Functions reference files type libraries declarations scope
dll user32 #SendMessage hWnd wMsg wParam lParam dll user32 #FindWindow $lpClassName $lpWindowName dll user32 #GetCursorPos POINT*lpPoint dll msvcrt ^pow ^x ^y [tolower]#ToLower c [795]#ToUpper c dll "qm.exe" ^Round ^number [cDec] ;;cDec is optional dll msvcrt #sprintf $buffer $format ... ;;2 or more arguments