bejglee
Tag
Bejegyzések száma: 16

Sziasztok,

Nekem ez a 2 megoldás jött be az új MT4-el:
1.) Ehhez saját dll-t kell gyártani
C++ rész:

MT4_EXPFUNC BOOL __stdcall isFileExists(const wchar_t* fileName)
{
	if (!fileName) return(FALSE);
	struct _stat buffer;
	return((_wstat(fileName, &buffer) == 0) ? TRUE : FALSE);
}

MT4 rész:

#define LIBRARIES_PATH  "\\MQL4\\Libraries\\"

#import "example.dll"
   bool isFileExists(string);
#import
...
bool checkFile(string filemane)
{
   if(!isFileExists(StringConcatenate(TerminalInfoString(TERMINAL_DATA_PATH), LIBRARIES_PATH, fileName))) return(false);
   return(true);
}

2.) Ehhez nem :-)

#define LIBRARIES_PATH  "\\MQL4\\Libraries\\"

#import "kernel32.dll"
   int GetFileAttributesW(string);
#import
...
bool checkFile(string filemane)
{
   if(!isFileExists(StringConcatenate(TerminalInfoString(TERMINAL_DATA_PATH), LIBRARIES_PATH, fileName))) return(false);
   return(true);
}

bool isFileExists(string fileName, bool allowDirectories=false)
{
   int res = GetFileAttributesW(fileName);
   if (res == -1) return(false);
   if (res == 0x10 && !allowDirectories) return(false); // Ez mappa
   return(true);   
}