DLL and mql4

 

Hi all I have created a DLL that reads the data in a text file on the server and everything works correctly.
Now I want to split the URL in the DLL and pass part of the path as an input parameter in my mql code but it does not work.

my DLL is:

extern "C"
{

        __declspec(dllexport) int main(std::wstring Patch) 
        {
                std::ofstream fout(L"c:\\test\\_test.htm");
                std::wstring url = L"https://mysite.com/" + Patch;

                HINTERNET hopen = InternetOpen(L"MyAppName", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);


                if (hopen)
                {
                        DWORD flags = INTERNET_FLAG_DONT_CACHE;

                        if (url.find(L"https://") == 0) flags |= INTERNET_FLAG_SECURE;

                        HINTERNET hinternet = InternetOpenUrl(hopen, url.c_str(), NULL, 0, flags, 0);

                        if (hinternet)
                        {
                                char buf[10000];
                                DWORD received = 0;
                                int i;

                                while (InternetReadFile(hinternet, buf, sizeof(buf), &received))
                                {
                                        if (!received) break;
                                        //fout.write(buf, received);

                                        int I = 0; int II = 5;
                                        for (i = 0; i <= received; i++)
                                        {
                                                //-- my read code is good!!!
                                        }


                                        system("PAUSE");
                                }
                                InternetCloseHandle(hinternet);
                        }
                        InternetCloseHandle(hopen);

                }
                return 0;
        }
}

My code Test Mql4 is:


#import "Dll1.dll"

    
    int main(string Patch);
    
#import

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit(){    
   
   
   Print("Serial: ", main("Read.txt"));  
   


   return(INIT_SUCCEEDED);
  }
Help please, thank you
 
Help me please!
 
fly7680:
Help me please!
Please use the search engine to find how to pass a string to a DLL, this has been asked and answered several times.
 
Alain Verleyen:
Please use the search engine to find how to pass a string to a DLL, this has been asked and answered several times.
thanks with the sample.cpp I managed to solve
Reason: