how EA can open a file in dll - page 2

 
forex2start:

You may use _wfopen function to open file with "wchar_t *" type filename.

And this is my code:

 And it is a simple VC++ DLL project, no .def file required.

Can you show the mql5 test code also ?
 
angevoyageur:
Can you show the mql5 test code also ?

Sure, the code is very simple.

#import "TestDLL.dll"
void TestFile(string filename);
#import 

//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+

void OnStart()
  {
//---
   TestFile("test.txt");
  }
//+------------------------------------------------------------------+

After running the above mql5 script program, a "test.txt" file will be generated at the installation folder of MT5.

If we specify an absolute path, for example, "d:\\test.txt", the file will be created right there. 

Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Running MQL5 Program Properties
Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Running MQL5 Program Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Environment State / Running MQL5 Program Properties - Documentation on MQL5
 
forex2start:

You may use _wfopen function to open file with "wchar_t *" type filename.

And this is my code:

 And it is a simple VC++ DLL project, no .def file required.

thank you very much!!!

It's work!!!

So the string in metatrader is UNICODE!!!!!!, if you use char in the dll ,the program couldn't work normally

It‘s very interesting!!!!

At the first time , I realize the value of Unicode.

I met the trouble for two months ,but now it's not a problem .thank you !