How to use CopyFile from kernel32.dll?

 

Hi guys,

I use a button in my indicator to save a screenshot. This screenshot can only be saved to the MT4 data folder. Now I would like to copy it from there to my desktop by using CopyFile from kernel32.dll.

I found the description about CopyFile here: https://msdn.microsoft.com/en-us/library/windows/desktop/aa363851(v=vs.85).aspx

Now my problem is that I don't know which data type the parameters have to be. I guess the first and second parameter are strings and obviously the third is a bool.

I  tried to code a small script for testing purposes but nothing works... I also receive an error that the function CopyFile can't be found in kernel32.dll although it's mentioned on the Microsoft page that it is kernel32.dll.

Can someone help me with that?

#import "kernel32.dll"
   bool CopyFile (string existingFile, string newFile, bool overwrite);
#import
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   CopyFile("d:\GBPAUDM5.gif", "d:\GBPAUDM5a.gif", false);
  }
CopyFile function (Windows)
  • msdn.microsoft.com
Copies an existing file to a new file. The CopyFileEx function provides two additional capabilities. CopyFileEx can call a specified callback function each time a portion of the copy operation is completed, and CopyFileEx can be canceled during the copy operation. To perform this operation as a transacted operation, use the CopyFileTransacted...
Files:
test.PNG  7 kb
 
Marcus Riemenschneider:

Hi guys,

I use a button in my indicator to save a screenshot. This screenshot can only be saved to the MT4 data folder. Now I would like to copy it from there to my desktop by using CopyFile from kernel32.dll.

I found the description about CopyFile here: https://msdn.microsoft.com/en-us/library/windows/desktop/aa363851(v=vs.85).aspx

Now my problem is that I don't know which data type the parameters have to be. I guess the first and second parameter are strings and obviously the third is a bool.

I  tried to code a small script for testing purposes but nothing works... I also receive an error that the function CopyFile can't be found in kernel32.dll although it's mentioned on the Microsoft page that it is kernel32.dll.

Can someone help me with that?


The proper function spelling is CopyFileW

 
Just google for "Mt4 kernell32 File" and you find a lot about that!
 
Carl Schreiber:
Just google for "Mt4 kernell32 File" and you find a lot about that!

Awesome! It works! Thanks guys!

 
Ex Ovo Omnia:

The proper function spelling is CopyFileW


I am new to MQL so my question might be stupid, if we use kernel32.dll in indicators/EAs, will it work on MAC? isn't kernel32.dll only windows specific?

 
m_javed:

I am new to MQL so my question might be stupid, if we use kernel32.dll in indicators/EAs, will it work on MAC? isn't kernel32.dll only windows specific?


Yes, it is, but if you are using an emulator like WINE, they have their versions of kernel32, which are mostly compatible.

Reason: