MQL4 Reference
Basics
Variables
External functions definition
|
The type of external functions defined in another component of a program must be explicitly described.
The absence of such a definition may result in errors during the compilation, linkage, or execution of the program.
While describing an external object, the keyword of #import must be used with the reference to the module.
#import "user32.dll"
int MessageBoxA(int hWnd ,string szText,string szCaption,int nType);
int SendMessageA(int hWnd,int Msg,int wParam,int lParam);
#import "lib.ex4"
double round(double value);
#import
Import can be used to easily describe functions called from external DLLs or compiled EX4 libraries.
Pointers to variables can be passed to imported dll functions. Data of the string type are passed as a pointer
to the corresponding memory block (one should keep in mind that internal representation of string data consists of two parts:
the memory block length and the memory block pointer). If there is a need to pass data of the int or double
type, then the one-dimensional array of the corresponding type should be passed by reference as a parameter.
Example:
#import "some_lib.dll"
void PassIntegerByref(int& OneInt[]);
#import
int start()
{
int array[1];
//...
PassIntegerByref(array);
Print(array[0]);
//...
}
|
|
|