Download MetaTrader 5

How to use "kernel32::CompareFileTime"

To add comments, please log in or register
1000 paid orders are executed in Freelance service. Sign up!
Jinsong Zhang
15624
Jinsong Zhang 2011.08.10 11:44 

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

Jinsong Zhang
15624
Jinsong Zhang 2011.08.10 12:06  

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);
}

 

Jinsong Zhang
15624
Jinsong Zhang 2011.08.10 12:36  
and, how to use "kernel32::GetFileSize"? Thanks
Slawa
Moderator
6843
Slawa 2011.08.10 13:06  

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.

Slawa
Moderator
6843
Slawa 2011.08.10 13:10  
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...
Jinsong Zhang
15624
Jinsong Zhang 2011.08.11 07:03  
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?
Slawa
Moderator
6843
Slawa 2011.08.11 09:29  
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 

Jinsong Zhang
15624
Jinsong Zhang 2011.08.11 09:54  
Grouped File Operations - MQL4 Articles
  • www.mql5.com
Grouped File Operations - MQL4 Articles: examples of expert advisors and strategy tester
Jinsong Zhang
15624
Jinsong Zhang 2011.08.11 11:03  
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);
}

 

Slawa
Moderator
6843
Slawa 2011.08.11 11:17  

Why FindFirstFileA? There is ANSI version.

Use unicode version FindFirstFileW 

Jinsong Zhang
15624
Jinsong Zhang 2011.08.11 11:22  
stringo:

Why FindFirstFileA? There is ANSI version.

Use unicode version FindFirstFileW 

Thank you very much!
To add comments, please log in or register