Way to turn off DLL import during optimization w/ remote agents

To add comments, please log in or register
Anthony Garot
3607
Anthony Garot  

It turns out that optimization using remote farm network agents blocks when a DLL is available in the code.

The exact message is (are):

agent no DLL

And this makes sense to me. I fully understand why Metatrades would do this.

So my fix, for when I use remote agents, is to use a compiler directive. When the directive is set, the DLL is not imported, and dummy functions replace the DLL functions. So this works:

#ifndef USES_REMOTE_AGENTS
#import "kernel32.dll"
        int  GetTimeZoneInformation(int& TZInfoArray[]);
        void GetLocalTime(int& TimeArray[]);
        void GetSystemTime(int& systemTimeArray[]);
        bool SystemTimeToTzSpecificLocalTime(int& targetTZinfoArray[], int& systemTimeArray[], int& targetTimeArray[]);

        // PrintFormat("Error Code: %d", kernel32::GetLastError());
        int GetLastError(void);

        // Unicode version, use this in MT5
        bool CopyFileW(string lpExistingFileName,string lpNewFileName,bool bFailIfExists);
        bool DeleteFileW(string lpExistingFileName);
        int GetFileAttributesW(string lpFileName);
#import
#else
        int  GetTimeZoneInformation(int& TZInfoArray[]) { return -1; }
        void GetLocalTime(int& TimeArray[]) {}
        void GetSystemTime(int& systemTimeArray[]) {}
        bool SystemTimeToTzSpecificLocalTime(int& targetTZinfoArray[], int& systemTimeArray[], int& targetTimeArray[]) { return false; }
        //int GetLastError(void) { return -1; }
        bool CopyFileW(string lpExistingFileName,string lpNewFileName,bool bFailIfExists) { return false; }
        bool DeleteFileW(string lpExistingFileName) { return false; }
        int GetFileAttributesW(string lpFileName) { return -1; }
#endif

So my question:

Is there a better way to handle this so that I can still have the benefits of kernel32 when not using remote agents?

To add comments, please log in or register