ShellExecuteW(...) 在 MetaTrader 4 中是否只工作一次?

Does ShellExecuteW(...) work only once in MetaTrader 4 or not?

正在尝试使用 ShellExecuteW().

MQL4 启动 .exe

这个命令只能用一次吗?

#import "shell32.dll"   // MQL4-syntax-wrapper-Bo[#import]Container
                        // v-------------- caller-side interface to DLL
        int ShellExecuteW( int    hWnd,
                           int    lpVerb,
                           string lpFile,
                           int    lpParameters,
                           int    lpDirectory,
                           int    nCmdShow
                           );
#import                 // MQL4-syntax-wrapper-Eo[#import]Container

if (  cond == true ){
      ShellExecuteW( 0, "open", "D:\Execute.exe", "", "", 1 );
   }

A:短版

也许是,也许不是。

A:更深入一点 [TLDR]

事实: MT4 终端的流程控制/流程管理并没有什么优势,但是它允许您集成多条控制线来控制 MT4 终端内部(和外部......不仅通过 ShellExecuteW(...) ...)发生的事情。

MT4 终端根据 graph 支持以下进程(通过内置线程):

  1. { 0 | 1 } 个名为 MQL4-ExpertAdvisor
  2. 的单例实例
  3. { 0 | 1 } 个名为 MQL4-Script
  4. 的单例实例
  5. { 0 | 1 ... n } 个名为 MQL4-TechnicalIndicator
  6. 的功能受限实例

这些实例的性质在几个方面有所不同,但是与您的问题最接近的是,每个过程都有一个强制部分和一组任意部分。

说到原文 MQL4(大家可能已经注意到,自从 Build 7xx MQL4 语言语法越来越接近 MQL5,因此有时被标记为MQL4.5 :o) )

//\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
//
// MQL4 code ----------------------------------------------------------<BoF>------

// MQL4 code compiler directives' section -----------------------<BoS>

#import ...                // MQL4-syntax-wrapper-Bo[#import]Container
        ..
        .
#import                    // MQL4-syntax-wrapper-Eo[#import]Container

// MQL4 code compiler directives' section -----------------------<EoS>

// ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
//
// MQL4 code section ---------------------------- init() / start() / deinit()
//

int init(){    // this part is being run just once,
               //                        right upon an instance activation
   }

int start(){   // this part is being run just once, for an MQL4-Script
               //                        right upon an instance activation
               //                    run upon an FX-MarketEvent is being observed
               //                             in an MQL4-ExpertAdvisor
               //                             or
               //                             in an MQL4-TechnicalIndicator


   }
...
..
.
//
// MQL4 code ---------------------------------------------------------<EoF>------
//
//\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

因此,您的部署代码的确切位置,(重新)使用通用 DLL 服务(#import-ed 用于编译时对齐和动态链接(重新使用) 决定调用外部进程的次数。


诺塔贝内

有很多更智能的方法将 MT4 终端与外部进程或远程进程(云和网格)集成,而不仅仅是基于 DLL 的另一个盲人和聋人难以管理的 <localhost> 进程。

通常需要进程控制和进程之间的双向通信。

不要犹豫,问更多。

MT4(加上一些额外的工具)可以做到。