MQL4 - automated forex trading   /  

Forum

C/C++ DLL & MetaTrader

Back to topics list To post a new topic, please log in or register

avatar
118
rfiche 2006.08.29 02:38 
Hello,

Could anyone give me an example of how passing an int value by reference to a DLL function?

I have tried the following code:

C++:

main.cpp of MyDll.dll:
#define DLLIMPORT __declspec (dllexport)

...

DLLIMPORT void __stdcall GetIntValue(int &i) {
    i = 10;
}

MQL4:

Library (mydll_lib.mqh):
#import "MyDLL.dll"
 
void GetIntValue(int& i);
Script:
#include <mydll_lib.mqh>
 
int start() {
  int i = 0;
  GetIntValue(i);
  Comment(i);
}

This isn“t works :(

Attention.: The DLL was written with Dev-C++ 4.9.9.2

Thank You!
Graphic Expert Advisor: AutoGraf

Graphic Expert Advisor: AutoGraf

The article shows the workability of graphics in creation of a convenient interface to manage trading.


avatar
Moderator
5198
stringo 2006.08.29 10:52 
You cannot pass parameters by reference to dll functions. Arrays only.

See http://docs.mql4.com/basis/variables/extfunctions

avatar
118
rfiche 2006.08.29 16:30 
Stringo,

thank you very much.

Regards,

Renato.
Back to topics list  

To add comments, please log in or register