Download MetaTrader 5
To add comments, please log in or register
Add the thread to Favorites. Track the changes even faster!
trinitigrp
10
trinitigrp 2014.02.26 08:56 

Hi guys,

Can anybody help me out?

I used to have an EA that make use of kernel32.dll's CreateFileA & WriteFile function to output a textfile to my desktop. It was perfectly working before build 600. After the patch, the EA could not output the textfile anymore. I understand that FileWrite() function will only output the textfile to \MQL4\Files folder which is not what I wanted.

   FileName = "C:\\Users\\Lenovo\\Desktop\\data.txt";
   int hFile = CreateFileA(FileName,GENERIC_WRITE,FILE_SHARE_READ,0,CREATE_ALWAYS,0,0);    
   if(hFile!=INVALID_HANDLE)
   {
      string Buffer="Testing";
      int BytesWritten[1];
      BytesWritten[0]=0;
      int FileLength = StringLen(Buffer);      
      WriteFile(hFile,Buffer,FileLength,BytesWritten,0);
      CloseHandle(hFile);
   }
   else
   { 
      Print("Failed to clear datafile.");
   }
Simon Gniadkowski
Moderator
17963
Simon Gniadkowski 2014.02.26 09:07  
linearity:

Hi guys,

Can anybody help me out?

I used to have an EA that make use of kernel32.dll's CreateFileA & WriteFile function to output a textfile to my desktop. It was perfectly working before build 600. After the patch, the EA could not output the textfile anymore. I understand that FileWrite() function will only output the textfile to \MQL4\Files folder which is not what I wanted.

Have you tried using the Unicode version of your DLL based function ?
trinitigrp
10
trinitigrp 2014.02.26 09:35  
I think the kernell32 method was from https://www.mql5.com/en/articles/1540 and is outdated? Is there any other way of creating textfile in desktop?
Simon Gniadkowski
Moderator
17963
Simon Gniadkowski 2014.02.26 10:33  
linearity:
I think the kernell32 method was from https://www.mql5.com/en/articles/1540 and is outdated? Is there any other way of creating textfile in desktop?


Google is your friend . . .

From here: http://msdn.microsoft.com/en-us/library/windows/desktop/aa363858(v=vs.85).aspx

Unicode and ANSI names

CreateFileW (Unicode) and CreateFileA (ANSI)
/
To add comments, please log in or register