You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Functions are called according to certain rules - calling convention. MT4 is guaranteed to work with functions that adhere to __stdcall (a special case of a rule variant). To be sure that the exported function uses the aforementioned rules, it should look like this: void __stdcall AnyFn();
2. I know two ways to make library function export - with __declspec(dllexport) and with def file (it's easier, otherwise you have to struggle with function decoding in addition). In VS to include def file in the project, first add to project files, then add file name to: project properties/composer/input/module definition file.
P.S: Example project with def file are located in: terminal directory\ experts\samples\DLLSample.
PASSING PARAMETERS TO A DLL FUNCTION
1. When passing string variable, an array of char (ANSI character, takes 1 byte) is passed to DLL.
2. Passing int or double to the library will cause the variable to be copied, hence when you change the variable in the dll, there is no change in the dll:
3. To be able to change int and double variables declared in MQL, arrays should be passed:
4. When passing an array from string, struct MqlStr is passed to the DLL:
P.S.
Whenever an array or a string (string) is passed to the DLL, it is actually a pointer to a memory section (pointer) that is passed to the library as follows
void __stdcall fn(int *pointer) {} // like this. This way you can work as an array, for example, pointer[4] = 4.
void __stdcall fn(int &reference) {} // or so. But we will get access to only one element. It is relevant when passing an array of one element into the library.
I couldn't find a proper explanation for the * in front of the pointer, what is it for? Isn't it possible to do without it ?????
And a question on the way how to get text from a dll ???
I couldn't find a proper explanation for the * in front of the pointer, what is it for? Isn't it possible to do without it ?????
And a question on the way how to get text from a dll ???
1. Transferring a string to the IDC:
2. The * sign indicates that it is a pointer. In short, any variable has not only some value, but also an address where it is located in memory. Pointers can work with this address. This is an issue that needs to be well understood, I think you should check out the C++ books;1. Transferring a string to the IDC:
2. The * sign indicates that it is a pointer. In short, any variable has not only some value, but also an address where it is located in memory. Pointers can work with this address. It's an issue that needs to be well understood, so you may want to check out some C++ books;You just need to be careful with the global data in the library. The MCL programs run independently of each other (but share global variables because they are in the same thread), hence it is possible that several scripts will write and read to the same memory location (which is not good). This requires synchronization, e.g. by using critical sections. I emphasize that this is true for global data (declared outside functions). When functions are called, their own, independent set of variables is created.