Services. Are they up and running yet? - page 20

 
Алексей Тарабанов:
Service operates with data (quotes) with possibility to correct them, but does not allow to manage anything, in particular - windows of the terminal, which is what we need. Hence, the obvious conclusion: when closing a window is necessary, the service generates an obviously impossible quote for this window and the script attached to this window closes it when this quote is received.

At the top is a full-fledged service that manages the windows and Market Watch. But from somewhere, comments like this are coming from. Writing code helps.

 
fxsaber:

At the top is a full-fledged service that manages the windows and Market Watch. But from somewhere, comments like this are coming from. Writing code helps.

It's complete, but it doesn't work, and it can't work.

 
Алексей Тарабанов:

It's full-fledged, but it doesn't work, and can't work.

Removed your ban in ME, try it out.

 
fxsaber:

Removed your ban in ME, try it out.

Breaking?

 
And I'm thinking. I like to think.
 
fxsaber:

Removed your ban in ME, try it out.

If that was you, thank you. I think it was Renat.

 
Will there be anything on the subject?
 
Will it be possible to run the service when starting the terminal, or is it already there?
Running multiple copies of the same service?
Passing parameters, or at least one to identify each running copy.
 
Wrote a useful service
// Сервис проверяет наличие корректной папки Tester.
#property service

input string inFolderName = "Tester";

#include <WinAPI\fileapi.mqh>
#include <WinAPI\handleapi.mqh>

#define  GENERIC_WRITE                    0x40000000
#define  CREATE_ALWAYS                    2
#define  FILE_ATTRIBUTE_NORMAL            0x00000080
#define  FILE_FLAG_OVERLAPPED             0x40000000

bool FileIsInvalid_WinAPI( const string FileName )
{
  const HANDLE hFile = CreateFileW(FileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL);      
  const bool Res = (hFile != INVALID_HANDLE);
  
  if (Res)
  {
    CloseHandle(hFile);
    
    DeleteFileW(FileName);
  }
    
  return(Res);
}

void OnStart()
{
  const string FileName = TerminalInfoString(TERMINAL_PATH) + "\\" + inFolderName;

  if (!FileIsInvalid_WinAPI(FileName + "\\" + __FILE__))
    MessageBox(FileName + " is invalid!");  
}


When starting the Terminal, a warning appears immediately if the Tester folder is missing.


Great help if the Tester on RAMDrive should be

imdisk -a -o awe -s 3 G -m Z: -p "/fs:ntfs /q /y /v:MT5Tester"

mkdir z:\Tester
mklink /j Tester z:\Tester

mkdir cache
mklink /j z:\Tester\cache cache
 
fxsaber:

When you start the Terminal, a warning appears immediately if the Tester folder is missing.

Very handy indeed.

Rebooted the computer and forgot about RAMDrive. I start MT5 and it immediately reports a problem.

Reason: