mql4 ini file and dll

 

Hi i try to work with inifile but  unfortunately  is very complicated  in mql4 , i saw  a lib  in library but not work , therfore in  first time i try to usae fileread and many more  but not work also this solution , therefore i prefer use a dll  i created  this dll  in C in pelles

// libini.c

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>

// Funzione per leggere il valore di una chiave da un file INI
const char* ReadIniValue(const char* filename, const char* section, const char* key)
{
    static char value[256]; // Assumiamo che il valore della chiave non superi i 255 caratteri
    GetPrivateProfileString(section, key, "", value, sizeof(value), filename);
    return value;
}

and i have  create the dll iniWini.dll i put them in include (i suppose is  good  location) ,at this time i call  by the mql4


// Example.mq4

#import "libini.dll"
    const char* ReadIniValue(const char filename, const char section, const char key);
#import

void OnStart()
{

    string value = ReadIniValue("correlazioni.ini","soglia_minima","symbl");
    Print("Valore della chiave ", key, ":", value);
}

but  return me

2023.07.21 23:38:23.968    DEMADE3 AUDCHF,H1: unresolved import function call
2023.07.21 23:38:23.968    Cannot call 'iniWini.dll::ReadIniValue', 'iniWini.dll' is not loaded
2023.07.21 23:38:23.967    Cannot load 'iniWini.dll' [126]

why not import ? if  first time for me  that i use a dll  whats wrong ? o_O

thanks at all

Files:
iniWini.zip  10 kb
 
faustf:

Hi i try to work with inifile but  unfortunately  is very complicated  in mql4 , i saw  a lib  in library but not work , therfore in  first time i try to usae fileread and many more  but not work also this solution , therefore i prefer use a dll  i created  this dll  in C in pelles

and i have  create the dll iniWini.dll i put them in include (i suppose is  good  location) ,at this time i call  by the mql4


but  return me

2023.07.21 23:38:23.968    DEMADE3 AUDCHF,H1: unresolved import function call
2023.07.21 23:38:23.968    Cannot call 'iniWini.dll::ReadIniValue', 'iniWini.dll' is not loaded
2023.07.21 23:38:23.967    Cannot load 'iniWini.dll' [126]

why not import ? if  first time for me  that i use a dll  whats wrong ? o_O

thanks at all

Because your DLLs go into the folder "Libraries".


 

i try to move  but   return this

2023.07.22 10:15:37.372    DEMADE3 AUDCHF,H1: unresolved import function call
2023.07.22 10:15:37.372    Cannot find 'ReadIniValue' in 'iniWini.dll'

 
faustf #:

i try to move  but   return this

2023.07.22 10:15:37.372    DEMADE3 AUDCHF,H1: unresolved import function call
2023.07.22 10:15:37.372    Cannot find 'ReadIniValue' in 'iniWini.dll'

This means your DLL is now loaded, but the export symbols are not found.

The DLL must Export in >compatible mode<, or the function you are trying to import is missing or misspelled, or the signature is not correctly represented.

It is important to respect all details, especially the keyword "const" must also be correctly reflected.

EDIT:

It's the signature. In your DLL, you are using pointers, in mql you are not. Try using references in mql. Honestly, I don't remember precisely, but I think pointers in DLL function signatures can be fed with references from mql.

But I am sure mql documentation has hints on how to do it.
 

thanks  i try to resolve  in  this mode

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>

// Funzione per leggere il valore di una chiave da un file INI
const char* ReadIniValue(const char* filename, const char* section, const char* key, char* value, int valueSize)
{
    GetPrivateProfileString(section, key, "", value, valueSize, filename);
    return value;
}

but  nothing  return me

2023.07.24 09:13:10.952    DEMADE3 AUDCHF,H1: not initialized
2023.07.24 09:13:10.952    DEMADE3 AUDCHF,H1: unresolved import function call
2023.07.24 09:13:10.952    Cannot find 'ReadIniValue' in 'iniWini.dll'

 

i have also a dubt i create a dll in C  but  i find  some example in youtube  that  use c++  but  is  possible in C ? or  i must use  c++ ? thanks

 
I think you are overcomplicating all things.
Treat ini file as plain text and use mql commands for file opening and reading.
 
faustf #:

i have also a dubt i create a dll in C  but  i find  some example in youtube  that  use c++  but  is  possible in C ? or  i must use  c++ ? thanks

The language you use is irrelevant as long as the corresponding compiler can create DLLs.

Try to find an example that works, implement that example, make it work. Then change it to your needs.
 
Fabio Cavalloni #:
I think you are overcomplicating all things.
Treat ini file as plain text and use mql commands for file opening and reading.

i just try with open file  etc but  is not good solution for operate in ini

 
Dominik Christian Egert #:
The language you use is irrelevant as long as the corresponding compiler can create DLLs.

Try to find an example that works, implement that example, make it work. Then change it to your needs.
thanks i  find
Reason: