MT4 release 1160 (and later) broke ability to call InternetOpenW()

To add comments, please log in or register
saleyn
80
saleyn  

Attached is a small script that calls InternetOpenW() (you need to enable DLL calls in your MT4 settings).

This script runs successfully without errors in MT4 releases prior to 1160.

In the builds 1160 and 1170 the call to InternetOpenW() returns error code 6 (invalid handle).

Is there a workaround?

MT4 release 1160 (and 1170) broke ability to call InternetOpenW()
MT4 release 1160 (and 1170) broke ability to call InternetOpenW()
  • 2018.12.27
  • www.mql5.com
Attached is a small script that calls InternetOpenW() (you need to enable DLL calls in your MT4 settings...
Files:
TestInet.mq4 1 kb
Mohammad Hossein Sadeghi
2656
Mohammad Hossein Sadeghi  
saleyn:

Attached is a small script that calls InternetOpenW() (you need to enable DLL calls in your MT4 settings).

This script runs successfully without errors in MT4 releases prior to 1160.

In the builds 1160 and 1170 the call to InternetOpenW() returns error code 6 (invalid handle).

Is there a workaround?

Read the documentation for this function on MSDN, you should not use empty string for lpszProxy and lpszProxyBypass, use NULL.

InternetOpenW function
InternetOpenW function
  • 2018.12.05
  • windows-sdk-content
  • docs.microsoft.com
Initializes an application's use of the WinINet functions.
saleyn
80
saleyn  
Mohammad Hossein Sadeghi:

Read the documentation for this function on MSDN, you should not use empty string for lpszProxy and lpszProxyBypass, use NULL.

I tried both initializing string as NULL and as an empty string, but both calls in MT4 build 1160 and later result in InternetOpenW() returning NULL and system error 6.

Note that this NOT observed with given script in earlier MT4 builds.

Mohammad Hossein Sadeghi
2656
Mohammad Hossein Sadeghi  
saleyn:

I tried both initializing string as NULL and as an empty string, but both calls in MT4 build 1160 and later result in InternetOpenW() returning NULL and system error 6.

Note that this NOT observed with given script in earlier MT4 builds.

I used your script and it works on Windows 10, and MT4 build 1170.

2018.12.28 07:12:08.398 Script TestInet AUDCAD,H1: removed
2018.12.28 07:12:08.397 TestInet AUDCAD,H1: uninit reason 0
2018.12.28 07:12:08.327 TestInet AUDCAD,H1: Success
2018.12.28 07:12:08.327 TestInet AUDCAD,H1: initialized
2018.12.28 07:12:08.327 Script Test\TestInet AUDCAD,H1: loaded successfully

You may need to reset the setting of Internet Explorer at Control Panel.
saleyn
80
saleyn  
Mohammad Hossein Sadeghi:

I used your script and it works on Windows 10, and MT4 build 1170.

2018.12.28 07:12:08.398 Script TestInet AUDCAD,H1: removed
2018.12.28 07:12:08.397 TestInet AUDCAD,H1: uninit reason 0
2018.12.28 07:12:08.327 TestInet AUDCAD,H1: Success
2018.12.28 07:12:08.327 TestInet AUDCAD,H1: initialized
2018.12.28 07:12:08.327 Script Test\TestInet AUDCAD,H1: loaded successfully

You may need to reset the setting of Internet Explorer at Control Panel.

Were you running it on a 32bit or 64bit OS?

Running this script on Windows Server 2012 32bit is successful, however, I am getting the same error on all 64bit Windows 10 machines (tested 4 of them).

Which settings do you suggest to reset in Control Panel?

Mohammad Hossein Sadeghi
2656
Mohammad Hossein Sadeghi  
saleyn:

Were you running it on a 32bit or 64bit OS?

Running this script on Windows Server 2012 32bit is successful, however, I am getting the same error on all 64bit Windows 10 machines (tested 4 of them).

Which settings do you suggest to reset in Control Panel?

It's 64bit. Just default setting: Control Panel>Internet Options>Advanced(tab)>Reset.

saleyn
80
saleyn  
Mohammad Hossein Sadeghi:

It's 64bit. Just default setting: Control Panel>Internet Options>Advanced(tab)>Reset.

Resetting Internet Options doesn't seem to help, still getting same error:

2018.12.28 11:33:50.814 TestInet BTCUSD,Daily: uninit reason 0
2018.12.28 11:33:50.814 TestInet BTCUSD,Daily: Error in InternetOpenW: 6
2018.12.28 11:33:50.814 TestInet BTCUSD,Daily: initialized
2018.12.28 11:33:50.807 Script Test\TestInet BTCUSD,Daily: loaded successfully

Same result on 4 different machines.

The question is really why does it work with MT4 builds prior to 1160, and doesn't work with the 1160 onward?

Below is the result of running the same script on the same machine, MT4 build 1090:

2018.12.28 12:12:13.328 TestInet AUDCHF,Daily: uninit reason 0
2018.12.28 12:12:13.328 TestInet AUDCHF,Daily: Success
2018.12.28 12:12:13.328 TestInet AUDCHF,Daily: initialized
2018.12.28 12:12:13.322 Script Test\TestInet AUDCHF,Daily: loaded successfully
Clearly this seems to have something to do with the MT4 upgrade.
Mohammad Hossein Sadeghi
2656
Mohammad Hossein Sadeghi  
saleyn:

Resetting Internet Options doesn't seem to help, still getting same error:

Same result on 4 different machines.

The question is really why does it work with MT4 builds prior to 1160, and doesn't work with the 1160 onward?

Below is the result of running the same script on the same machine, MT4 build 1090:

Clearly this seems to have something to do with the MT4 upgrade.

Try this code:

//+------------------------------------------------------------------+
//|                                                     TestInet.mq4 |
//+------------------------------------------------------------------+
#property strict

#import "Wininet.dll"
int InternetAttemptConnect(int x);
//int InternetOpenW(string &sAgent,int lAccessType,string &sProxyName,string &sProxyBypass,int lFlags);
int InternetOpenW(string sAgent,int lAccessType,string sProxyName,string sProxyBypass,int lFlags);
int InternetCloseHandle(int hInet);
#import

#import "ntdll.dll"
  int RtlGetLastWin32Error();
#import

void OnStart()
{
  int rv = InternetAttemptConnect(0);
  if (rv != 0)
    PrintFormat("Error in InternetAttemptConnect: %d", RtlGetLastWin32Error());

  string user_agent="Mozilla";
  //string nill="";
  //int session=InternetOpenW(user_agent,0,nill,nill,0);
  int session=InternetOpenW(user_agent,0,NULL,NULL,0);
  if (session==0)
    PrintFormat("Error in InternetOpenW: %d", RtlGetLastWin32Error());
  else {
    Print("Success");
    InternetCloseHandle(session);
  }
}

Strings are passed by value when importing and NULL is passed to InternetOpenW instead of nill.

saleyn
80
saleyn  
Mohammad Hossein Sadeghi:

Try this code:

Strings are passed by value when importing and NULL is passed to InternetOpenW instead of nill.

Same result with the error:

2018.12.28 13:00:28.248 TestInet NZDCHF,M5: uninit reason 0
2018.12.28 13:00:28.248 TestInet NZDCHF,M5: Error in InternetOpenW: 6
2018.12.28 13:00:28.247 TestInet NZDCHF,M5: initialized
2018.12.28 13:00:28.237 Script Test\TestInet NZDCHF,M5: loaded successfully
Alain Verleyen
38674
Alain Verleyen  
saleyn:

Same result with the error:

Works for me. Windows 10/64 MT4 1170.

2018.12.28 16:05:23.400    296477 EURUSD,H1: initialized
2018.12.28 16:05:23.478    296477 EURUSD,H1: Success
2018.12.28 16:05:23.500    296477 EURUSD,H1: uninit reason 0

saleyn
80
saleyn  

I have hard time understanding the cause of this problem.

I tried running this script on 4 Windows 10 machines (with latest upgrades) on PCs in 2 different networks, and consistently get errors in 1170 MT4 build, while getting successful results on MT4 built 1090 running on the same machines.  The only variable is the versions of MT4 software.

According to several users in this thread they can't reproduce this problem on build 1170.

This is rather annoying, and makes some of the EAs and indicators I've written that have been working for years unusable with the latest MT4 builds.

12
To add comments, please log in or register