dll[-] dllfile [functype]Function [parameters]
dll[-] dllfile (tab)[functype]Function1 [parameters] [(tab)[functype]Function2 [parameters] ...]
Use this syntax to declare different name (alias) than it is in dll:
dll dllfile [TrueName][functype]AnyName [parameters]
Use this syntax to retrieve the function by its ordinal number:
dll dllfile [ordinal][functype]AnyName [parameters]
dllfile - dll filename or full path.
functype - return type. If omitted, the return value is undefined (void).
Function - name.
parameters - list of parameters.
| - | Delay-loading. |
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 parameters. They are declared by enclosing into [ ]. The default value is 0. User-defined types passed by value cannot be optional.
QM 2.2.1: To declare variable number of parameters, add ... at the end. When calling the function, argument types are not converted, therefore must match expected.
Allowed is function declaration without parameters. When calling such function, can be passed 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 parameters