Forex programozás › Fórum › Kérdések az MQL4 programozási nyelvvel kapcsolatban › kernel32.dll › Válasz erre: kernel32.dll
Nekem a fentiek nem működtek az új MT4-ben, ezért ezt használom:
#import "Kernel32.dll"
int GetFileAttributesA(uchar& lpFileName[]);
#import
int init()
{
if (!FileExists( CustomIndicator+".ex4"))
Alert(Symbol()+", "+comment+": Hiba! "+CustomIndicator+".ex4 nincs meg.");
}
//-----------------------------------------------------------------------------
// function: FileExists()
// Description: Check if a file exists
//-----------------------------------------------------------------------------
bool FileExists(string sIndicatorName) {
char szFileName[255];
string sFile=TerminalPath()+"\\MQL4\\Indicators\\"+sIndicatorName;
StrCpy(sFile,szFileName,sizeof(szFileName));
if (GetFileAttributesA(szFileName)==-1) {
return(False);
}
return(True);
}
//-----------------------------------------------------------------------------
// function: StrCpy()
// Description: Copy string to null terminated char array
// (for dll string parameter in mql4.5)
//-----------------------------------------------------------------------------
int StrCpy(string sSrc, uchar& szDest[], int iMaxSize) {
for (i=0; i<MathMin(StringLen(sSrc),iMaxSize-1); i++) {
szDest[i]=(uchar)StringGetChar(sSrc,i);
}
if (iMaxSize>0)
szDest[i]=0;
return(i);
}