I am a first timer in this community of business and I'm bit nervous of losing everything at the end of the day,something would be encouragable regarding a platform suitable either to set a pase for me, otherwise I'm pleased to participate as agreed. thank you.
bool openURL(string url){ int APPEND = FILE_CSV|FILE_WRITE; string file = MQLInfoString(MQL_PROGRAM_NAME) + ".URL"; int handle = FileOpen(file, APPEND, '~'); if (handle < 1){ int GLE = GetLastError();Print("Last Error Code: "+(string)GLE);ResetLastError();} FileWrite(handle, "[InternetShortcut]"); FileWrite(handle, "URL="+url); FileClose(handle); return(Shell(TerminalInfoString(TERMINAL_DATA_PATH)+"\\MQL5\\Files\\"+file)); // or "cmd.exe", "/C "+file }
- Path is wrong per Ernst.
- MT5 is a 64 bit application. Perhaps you can use the 64 bit one.
On a 64 bit system,, the 64 bit shell32.dll is in the System32 directory and the 32 bit shell32.dll is in the SysWOW64 directory.
Shell32 in 64 bit?
Paying forward and helping out others, here is the version that is tested and works for MT5, after putting together the comments from the messages above. Thanks everyone !
//+------------------------------------------------------------------+ //| browseOpener.mq5 | //+------------------------------------------------------------------+ #property copyright "" #property link "" #property version "1.00" #property strict #property script_show_inputs //--- input parameters input string urltoopen = "www.google.com"; //URL to open //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { //--- openURL(urltoopen); } bool openURL(string url){ string file = WindowExpertName() + ".URL"; int handle = FileOpen(file, FILE_CSV|FILE_WRITE , '~'); if (handle < 1){ int GLE = GetLastError();Print("Last Error Code: "+(string)GLE);ResetLastError();} FileWrite(handle, "[InternetShortcut]"); FileWrite(handle, "URL="+url); FileClose(handle); return ( Shell(TerminalInfoString(TERMINAL_DATA_PATH)+"\\MQL4\\Files\\"+file) ); // or "cmd.exe", "/C "+file } #import "shell32.dll" int ShellExecuteW(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=ShellExecuteW(0, OPERATION, file, parameters, DEFDIRECTORY, SW_SHOWNORMAL); if (r > 32) return(true); //Alert("Shell failed: ",r); return(false); }
Discover new MetaTrader 5 opportunities with MQL5 community and services
- 2022.07.22
- www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
TheCoder #:
Paying forward and helping out others, here is the version that is tested and works for MT5, after putting together the comments from the messages above. Thanks everyone !
Small observation - I found this line does not compile in MQL5:
string file = WindowExpertName() + ".URL";
I changed it after which it compiled
string file = __FILE__ + ".URL";
Also had to change MQL4 to MQL5 but it worked after that - nicely done!
return ( Shell(TerminalInfoString(TERMINAL_DATA_PATH)+"\\MQL5\\Files\\"+file) ); // or "cmd.exe", "/C "+file
Very simple, Mt4 Open url ,
Shell32::ShellExecuteW
Mt5 Open Url
int r=ShellExecuteW
#import "shell32.dll" int ShellExecuteW(int hwnd, string Operation, string File, string Parameters, string Directory, int ShowCmd); #import int r=ShellExecuteW(0, "open", "www.mql5.com", "", "", 3); // Mql5 //Shell32::ShellExecuteW(0, "open", "www.mql5.com", "", "", 3); // Old Model mql4
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Currently I am Using the Below Code In MQL4,
This Work Perfectlly In MQL4.
I don't know anything about these dll and advanced stuff (Can Someone Also Suggest How To Learn About these Advanced Things?).
I just copied this code from a MQL4 forum.
I have tried to use it in MT5 (Of course after removing few error caused due to migration to MQL5)
But It Doesn't Work.
Can Someone Help Me With MQL5 Version Of This?