Download MetaTrader 5
To add comments, please log in or register
Download MQL5 library codes via MetaTrader. It is convenient!
kashif
129
kashif 2008.07.25 22:11 

Hello,

Using EA, can i open an html file with a browser. If some some one know please let me know.



Thanks,

Do Hung
147
Do Hung 2012.10.02 07:11  

Sorry to request very old question.

I want a code that EA can open a default web browser with given URL.

Please help.

Thanks!

whroeder1
13656
whroeder1 2012.10.02 12:47  
Untested
bool openURL(string url){
    int APPEND  = FILE_CSV|FILE_WRITE;
    string  file = WindowExpertName() + ".URL";
    int handle   = FileOpen(file, APPEND, '~');
    if (handleOPT < 1){ int GLE = GetLastError(); ... }
    FileWrite(handleOPT, "[InternetShortcut]");
    FileWrite(handleOPT, "URL="+url);
    FileClose(handleOPT);
    return ( Shell(TerminalPath()+"\\experts\\files\\"+file) );     // or "cmd.exe", "/C "+file
}
#import "shell32.dll"
   int ShellExecuteA(int hWnd, string Verb, string File, string Parameter, string Path, int ShowCmd);
#import
bool Shell(string file, string parameters=""){
    #define DEFDIRECTORY NULL
    #define OPERATION "open"    // or print
    #define SW_SHOWNORMAL 1
    int r=ShellExecuteA(0, OPERATION, file, parameters, DEFDIRECTORY, SW_SHOWNORMAL);
    if (r > 32) return(true);
    Alert("Shell failed: ",r);
    return(false);
}
Untested
whroeder1
13656
whroeder1 2015.06.15 16:40  
  1. Since build 600 Feb 2014, all strings are Unicode. ShellExecuteA must be changed to ShellExecuteW. See also https://www.mql5.com/en/forum/155323
  2. open a url i n browser - MQL4 forum
/
To add comments, please log in or register