when I use the ChangeAccount method , it's works well
but it can't get login message , so we won't be able to know the result of the login, especially if the login fails for some reason.
We can get the latest information by reading the log file.
But unfortunately MT4 will take a long time to update the log file.
After I found a lot of information, I found the following method:
1, through some methods to make MT4 update the log file immediately
2, read the log file, and find the abnormal login information from it
the code : (in c# It can also be implemented using MQL, only need to import the commands in user32.dll)
IntPtr _tmHandle=Terminal handle;
while (_tmHandle!=IntPtr.Zero)
{
Thread.Sleep(300);
WindowsApi.SendMessage(_tmHandle,WindowsApiMsg.WM_COMMAND, 33117, 0); //open the log details window
bool find = false;
for (int i = 0; i < 10; i++)
{
Thread.Sleep(100);
IntPtr LogHandle = WindowsApi.FindWindowEx(IntPtr.Zero, IntPtr.Zero, null, @"\Logs");
if (LogHandle != IntPtr.Zero)
{
find = true;
WindowsApi.SendMessage(LogHandle, WindowsApiMsg.WM_CLOSE, 0, 0); //close the folder
}
else if (find)
{
break;
}
}
}
Reading the log file and analyzing the content is very simple, can write it yourself as needed.
when I use the ChangeAccount method , it's works well but it can't get login message , so we won't be able to know the result of the login, especially if the login fails for some reason. We can get the latest information by reading the log file. But unfortunately MT4 will take a long time to update the log file. After I found a lot of information, I found the following method: 1, through some methods to make MT4 update the log file immediately 2, read the log file, and find the abnormal login information from it
the code : (in c# It can also be implemented using MQL, only need to import the commands in user32.dll)
IntPtr _tmHandle=Terminal handle; while (_tmHandle!=IntPtr.Zero) { Thread.Sleep(300); WindowsApi.SendMessage(_tmHandle,WindowsApiMsg.WM_COMMAND, 33117, 0); //open the log details window bool find = false; for (int i = 0; i < 10; i++) { Thread.Sleep(100); IntPtr LogHandle = WindowsApi.FindWindowEx(IntPtr.Zero, IntPtr.Zero, null, @"\Logs"); if (LogHandle != IntPtr.Zero) { find = true; WindowsApi.SendMessage(LogHandle, WindowsApiMsg.WM_CLOSE, 0, 0); //close the folder } else if (find) { break; } } }
Reading the log file and analyzing the content is very simple, can write it yourself as needed.