configmql4mt4

Parsing MT4 config files


I'm trying to write an install script for an MT4 expert advisor. Part of the installation process includes adding an allowed WebRequest URL. I assume this is saved as a setting in C:\Users\{User ID}\AppData\Roaming\MetaQuotes\Terminal\{Terminal ID}\config\experts.ini as I can see the allowed URLs there, but I cannot parse this data as no editor I have can decode it. Is this file parsed using a proprietary encoding or is it encrypted in some way? Any help here would be appreciated.


Solution

  • The only solution I could think of to address this issue was to create my own HTTP web request library, here, and use it to submit HTTP requests.

    #include <mql-http/Request.mqh>
    #include <mql5-json/Json.mqh>
    
    int SendWebRequest(const object request) {
    
       string body = ConvertToJSON(request);  // You'll have to write your own JSON converter
       
       HttpRequest req("POST", m_send_addr, body);
       req.AddHeader("Accept", "application/json");
       req.AddHeader("Authorization", m_auth_header);
       
       HttpResponse resp;
       int errCode = req.Send(resp);
       if (errCode != 0) {
          return errCode;
       } else if (resp.StatusCode != 200) {
          return resp.StatusCode;
       } else {
          return 0;
       }
    }
    

    At the moment this is pretty bare-bones but it's open-source so feel free to modify and contribute.