This code has worked flawlessly for me up until testing it in MT4 build 600, where it no longer verifies accounts from my server.
Thanks for your suggestion angevoyageur, but I tried switching all the ansi 'A' to W but still no dice.
Your problem is going to be with InternetReadFile(). See EasyXml.mqh at https://www.mql5.com/en/code/1998 for an example of how to use WinInet functions in the new MQL4 - the code works both in MQL4 and MQL5.
In essence, you pass a uchar[] array to InternetReadFile(), and then convert the array to a string using CharArrayToString(). What you can in effect now do in MQL4 is to allocate managed memory buffers of arbitrary length, pass them to a DLL, and then convert the data from Ansi or Unicode as applicable.
In essence, you pass a uchar[] array to InternetReadFile(), and then convert the array to a string using CharArrayToString(). What you can in effect now do in MQL4 is to allocate managed memory buffers of arbitrary length, pass them to a DLL, and then convert the data from Ansi or Unicode as applicable.
Broadening out the topic and answer slightly... in the new MQL4 it's possible to call either the A or W versions of many functions. For example, the following script gets the Windows temporary directory using both the GetTempPathA and GetTempPathW calls:
#import "kernel32.dll" int GetTempPathA(int,uchar & arr[]); int GetTempPathW(int,short & arr[]); #import void OnStart() { uchar AnsiStringBuffer[256]; GetTempPathA(255, AnsiStringBuffer); string strTempPathFromA = CharArrayToString(AnsiStringBuffer); short UnicodeStringBuffer[256]; GetTempPathW(255, UnicodeStringBuffer); string strTempPathFromW = ShortArrayToString(UnicodeStringBuffer); Print("Temp path via GetTempPathA(): ", strTempPathFromA); Print("Temp path via GetTempPathW(): ", strTempPathFromW); }
Therefore, it's possible to continue using many Ansi-only DLL calls from the new MQL4: not necessarily a need to update both the MQL4 code and the DLL.
Therefore, it's possible to continue using many Ansi-only DLL calls from the new MQL4: not necessarily a need to update both the MQL4 code and the DLL.
... Another example: passing string values into an Ansi DLL call from the new MQL4. (In real life you would obviously just call MessageBoxW rather than using this workaround to call MessageBoxA, but the general point is useful)
#import "user32.dll" // Declare the Ansi function as taking uchar[] input parameters instead of strings int MessageBoxA(int,uchar & arr1[],uchar & arr2[],int); #import void OnStart() { string strMessage = "Hello"; string strTitle = "Hi!"; // Convert the strings to uchar[] arrays uchar ucMessage[], ucTitle[]; StringToCharArray(strMessage, ucMessage); StringToCharArray(strTitle, ucTitle); MessageBoxA(0, ucMessage, ucTitle, 64); }
I've played around with this for a few hours now, still no luck. So yea, looking to hire someone to do this for me ;)
I've played around with this for a few hours now, still no luck. So yea, looking to hire someone to do this for me ;)
See https://www.mql5.com/en/forum/149360 - I was about to post this as answer here, but then found a problem...
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
This code has worked flawlessly for me up until testing it in MT4 build 600, where it no longer verifies accounts from my server.