Download MetaTrader 5
To add comments, please log in or register
Download MetaTrader 5 for iPad and trade anywhere!
ankityadav
208
ankityadav 2014.04.02 13:43  
qjol:

You already have all the answers you need in this post
The question is do you just want someone to write for you the entire code

NO Dear I want a sample code by which i can use then try that's it If you help me then that will be more helpfull for me
Carl Schreiber
6125
Carl Schreiber 2014.04.02 13:43  

This function is defined in WinFile_v600.mqh around line 152:

int OpenNewFileForWriting(string FileName, bool ShareForReading = false)
{
   int ShareMode = 0;
   if (ShareForReading) ShareMode = WIN32_FILE_SHARE_READ;
   return (CreateFileW(FileName, GENERIC_WRITE, ShareMode, 0, CREATE_ALWAYS, 0, 0));
}



ankityadav
208
ankityadav 2014.04.02 13:52  
gooly:

This function is defined in WinFile_v600.mqh around line 152:



Hi thanks getting some idea i have added WinFile_v600.mqh but having still error

'OpenNewFileForWriting' - function already defined and has body I am using this code to read the open the file in the particular path

//+------------------------------------------------------------------+
//|                                              File Read Write.mq4 |
//|                      Copyright © 2008, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net/"

// êîíñòàíòû äëÿ ôóíêöèè _lopen
#define OF_READ               0
#define OF_WRITE              1
#define OF_READWRITE          2
#define OF_SHARE_COMPAT       3
#define OF_SHARE_DENY_NONE    4
#define OF_SHARE_DENY_READ    5
#define OF_SHARE_DENY_WRITE   6
#define OF_SHARE_EXCLUSIVE    7
#include <WinFile_v600.mqh>
#import "kernel32.dll"
   int _lopen  (string path, int of);
   int _lcreat (string path, int attrib);
   int  GetEnvironmentVariableW (string lpName, string& lpBuffer, int nSize);
   int _llseek (int handle, int offset, int origin);
   int _lread  (int handle, string buffer, int bytes);
   int _lwrite (int handle, string buffer, int bytes);
   int _lclose (int handle);
#import

int start()
  {
//----
      string fName=" ";
        string f = "12345678 1 2345678 2 2345678 3 2345678 4 2345678 5 2345678 6 2345678 7 2345678 8 2345678 9 23456789";
        GetEnvironmentVariableW("USERPROFILE", f, StringLen(f));
        fName = f + "C:\Documents and Settings\Administrator\My Documents\Downloads\test.text" + fName;
        int handle;
        handle=OpenNewFileForWriting(fName);  
//----
   return(0);
  }
  int OpenNewFileForWriting(string FileName, bool ShareForReading = false)
{
   int ShareMode = 0;
   if (ShareForReading) ShareMode = WIN32_FILE_SHARE_READ;
   return (CreateFileW(FileName, GENERIC_WRITE, ShareMode, 0, CREATE_ALWAYS, 0, 0));
}
   
Carl Schreiber
6125
Carl Schreiber 2014.04.02 13:58  
may be you have to pay s.o. to code this for you or you have to read the MT4-docs.
ankityadav
208
ankityadav 2014.04.02 13:59  
gooly:
may be you have tp pay s.o. to code this for you or you have to read the MT4-docs.

so you are not going to help right ??Please just need a sample code ???
Carl Schreiber
6125
Carl Schreiber 2014.04.02 14:04  

It is frustrating and needless to help you if you obviously do not understand what this means:

'OpenNewFileForWriting' - function already defined

and change your code accordingly.

ankityadav
208
ankityadav 2014.04.02 14:18  
gooly:

It is frustrating and needless to help you if you obviously do not understand what this means:

'OpenNewFileForWriting' - function already defined

and change your code accordingly.


Yes understand thanks for your help now I need to read the file and write theis this function i have to for reading and writing the file the file ??If yes then what the buffer and bytes here ??

int _lread (int handle, string buffer, int bytes);

int _lwrite (int handle, string buffer, int bytes);

qjol
3243
qjol 2014.04.02 14:44  

you already using

#include <WinFile_v600.mqh>

no need to import the function again

ankityadav:

'OpenNewFileForWriting' - function already defined and has body I am using this code to read the open the file in the particular path

ankityadav
208
ankityadav 2014.04.02 14:46  
qjol:

you already using

no need to import the function again



Yes Got it i have changed my code and now its working
/ /1234
To add comments, please log in or register