ini file and dll library question

 

Hi guys  i  create a dll in c++  for visual studio 2019 for read ini file i suppose  is  correct the code  because compile  and  not return error , but unfortunately , when i call it,  by mql4  not return nothing , i follow this  tutorial https://www.mql5.com/en/blogs/post/753426#comment_48337118 , i suggest  this  tutorial because is  easy  and very step by step  and  author @lorio give a support , i am not  expert in c++ and  especially c++ for create dll , ( i modify a example that just worked ) this  is my code  in c++

#pragma once

#include "pch.h" // use stdafx.h in Visual Studio 2017 and earlier
#include <utility>
#include <limits.h>
#include <string>

#ifdef MYSIMPLEDLL_EXPORTS
#define MYSIMPLEDLL_API __declspec(dllexport)
#else
#define MYSIMPLEDLL_API __declspec(dllimport)
#endif

extern "C" MYSIMPLEDLL_API int ini_Read(const wchar_t* Paths_ini, const wchar_t* Section, const wchar_t* Key) {
    
    //int ReadIni = GetPrivateProfileInt(Section, Key, 0, Paths_ini);

    const int bufferSize = 256; // Dimensione del buffer per la stringa
    wchar_t  buffer[bufferSize];   // Buffer per memorizzare la stringa letta

    GetPrivateProfileString(Section, Key, NULL,  buffer, bufferSize, Paths_ini);
    std::wstring  userNumMax(buffer);
    
    return 0;
}

and this is my code in mql4

//+------------------------------------------------------------------+
//|                                                     TEST_DLL.mq4 |
//|                                  Copyright 2023, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2023, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

#import "Dll2.dll"
string ini_Read(string a,string b,string c);
#import


int OnInit()
  {
  string result=ini_Read("correlazioni.ini","soglia_minima","symbl4");
  Print("DLL says "+ result);
  return(INIT_SUCCEEDED);
  }

void OnDeinit(const int reason)
  {
  }

void OnTick()
  {

in attach my inifile and  my visualstudio project , if  anyone  have some suggestion is  welcome  thanks  again at  all

Create DLL , simplest form example
Create DLL , simplest form example
  • 2023.07.07
  • www.mql5.com
Hi!  First things first you need visual studio for this .  Install it , start it up
Files:
Dll2.zip  13245 kb
 
faustf:

Hi guys  i  create a dll in c++  for visual studio 2019 for read ini file i suppose  is  correct the code  because compile  and  not return error , but unfortunately , when i call it,  by mql4  not return nothing , i follow this  tutorial https://www.mql5.com/en/blogs/post/753426#comment_48337118 , i suggest  this  tutorial because is  easy  and very step by step  and  author @lorio give a support , i am not  expert in c++ and  especially c++ for create dll , ( i modify a example that just worked ) this  is my code  in c++

and this is my code in mql4

in attach my inifile and  my visualstudio project , if  anyone  have some suggestion is  welcome  thanks  again at  all

Are you trying to read a mt4 ini file ?

 
yes i saw  a library for do that  but  not  work , therfore i try to create  in mql4  but  is  a long  work , i look the dll system and  tell me  why not  try ? also becaus in c++  i think  is much short
 
faustf #:
yes i saw  a library for do that  but  not  work , therfore i try to create  in mql4  but  is  a long  work , i look the dll system and  tell me  why not  try ? also becaus in c++  i think  is much short

Where is that file placed ? (that you are reading)

 
Lorentzos Roussos #:

Where is that file placed ? (that you are reading)

i attach
correlazioni.ini

the name is  .zip  the structure is like this


[primario]
symbl1=AUDUSD
symbl2=AUDJPY
symbl3=NZDJPY
symbl4=AUDJPY
symbl5=GBPAUD
symbl6=EURUSD
symbl7=EURAUD
symbl8=EURGBP
symbl9=EURUSD
[correlato]
symbl1=NZDUSD
symbl2=NZDJPY
symbl3=NZDUSD
symbl4=AUDUSD
symbl5=GBPNZD
symbl6=USDCHF
symbl7=AUDCHF
symbl8=GBPCHF
symbl9=USDDKK
[soglia_minima]
symbl10=0.4
symbl2=0.4
symbl3=0.4
symbl4=0.4
symbl5=0.4
symbl6=0.8
symbl7=0.8
symbl8=0.8
symbl9=0.8
 
faustf #:
i attach

the name is  .zip  the structure is like this


ow , you are downloading correlation data from somewhere .

 
Lorentzos Roussos #:

ow , you are downloading correlation data from somewhere .

no i have a  static  text  of  correlation

 
faustf #:

no i have a  static  text  of  correlation

so you have another "system" that produces that and you want to read it in mt4 

 

yes , explain  this  static   text iniside of  ini file i  have just  but  i  want  also add other  example  brent and  index  and more  but  different broker  have  different ticker , therfore i create  this index  ini file , the  user  before place robot  must insert a ticker that want  and  after  i mix  all in mql4

 
faustf #:

yes , explain  this  static   text iniside of  ini file i  have just  but  i  want  also add other  example  brent and  index  and more  but  different broker  have  different ticker , therfore i create  this index  ini file , the  user  before place robot  must insert a ticker that want  and  after  i mix  all in mql4

i see 

You could do it like this :

the export

Symbol1,Symbol2,Correlation!Symbol1,Symbol2,Correlation 
etc

So then you would split the string file by !

and then each part by , and you would get Symbol1 symbol2 and their correlation

 

but  where?

Reason: