How to use "kernel32::CompareFileTime"

 

Please, how to use "kernel32::CompareFileTime" in MQL5? thanks very much.

 

Here is my code, but I think the result is wrong.

#import "Kernel32.dll"

int CompareFileTime(string FilePath1, string FilePath2);
#import

string aa="E:\\Temp\\test1.txt";
string bb="E:\\Temp\\test1.txt";
string cc="E:\\Temp\\test2.txt";
void OnStart()
{
   int res1=-2,res2=-2;
   res1=kernel32::CompareFileTime(aa,bb);
   res2=kernel32::CompareFileTime(aa,cc);
   Print(res1," ",res2);
}

 

 
and, how to use "kernel32::GetFileSize"? Thanks
 

CompareFileTime Function

Compares two file times.

LONG WINAPI CompareFileTime(
  __in          const FILETIME* lpFileTime1,
  __in          const FILETIME* lpFileTime2
);

Parameters

lpFileTime1

A pointer to a FILETIME structure that specifies the first file time.

lpFileTime2

A pointer to a FILETIME structure that specifies the second file time.

 
song_song:
and, how to use "kernel32::GetFileSize"? Thanks
Welcome to the MSDN
GetFileSize function (Windows)
  • msdn.microsoft.com
Retrieves the size of the specified file, in bytes. Syntax Parameters hFile [in] A handle to the file. lpFileSizeHigh [out, optional] A pointer to the variable where the high-order doubleword of the file size is returned. This parameter can be NULL if the application does not require the high-order doubleword. Return value If the function...
 
stringo:

CompareFileTime Function

Compares two file times.

Parameters

lpFileTime1

A pointer to a FILETIME structure that specifies the first file time.

lpFileTime2

A pointer to a FILETIME structure that specifies the second file time.

Thanks, stringo. If I have to use "FindFirstFile" first? Can I use "kernel32::FindFirstFile" in MQL5? If I can, what's the type of WIN32_FIND_DATA in MQL5?
 
song_song:
Thanks, stringo. If I have to use "FindFirstFile" first? Can I use "kernel32::FindFirstFile" in MQL5? If I can, what's the type of WIN32_FIND_DATA in MQL5?

All the our structures are described in the documentation. There is no WIN32_FIND_DATA structure in MQL5.

You can use kernel32::FindFirstFile in MQL5. How to use see MSDN 

 
Grouped File Operations - MQL4 Articles
  • www.mql5.com
Grouped File Operations - MQL4 Articles: examples of expert advisors and strategy tester
 
stringo:

All the our structures are described in the documentation. There is no WIN32_FIND_DATA structure in MQL5.

You can use kernel32::FindFirstFile in MQL5. How to use see MSDN 

Please test my code, it always return -1.  I am sure there are .ex5 files in that folder. What's wrong?


#import "Kernel32.dll"
int FindFirstFileA(string FilePath, int& lpFindFileData[]);
int FindClose(int hFile);
#import

string file1="D:\MetaTrader5\MQL5\Experts\*.ex5";

void OnStart()
{
   
   int win32_DATA[79];
   int hFile=kernel32::FindFirstFileA(file1,win32_DATA);
   Print(hFile);
   if(hFile>0)FindClose(hFile);
}

 

 

Why FindFirstFileA? There is ANSI version.

Use unicode version FindFirstFileW 

 
stringo:

Why FindFirstFileA? There is ANSI version.

Use unicode version FindFirstFileW 

Thank you very much!