在ocaml中运行可执行(windows)文件

在ocaml中运行可执行(windows)文件,ocaml,exe,Ocaml,Exe,快速提问。如何在ocaml中运行可执行文件?我相信这是可能的,但我不知道怎么做 请提供示例代码。如果您只想运行一个程序而不想与之通信,请使用 对于更复杂的情况,您需要使用。不管名字如何,在Windows下工作。例如,如果需要从命令获取输出: let ch = Unix.open_process_in "c:\\path\\to\\executable.exe /argument" in try while true do let line = input_line ch in …

快速提问。如何在ocaml中运行可执行文件?我相信这是可能的,但我不知道怎么做


请提供示例代码。

如果您只想运行一个程序而不想与之通信,请使用

对于更复杂的情况,您需要使用。不管名字如何,在Windows下工作。例如,如果需要从命令获取输出:

let ch = Unix.open_process_in "c:\\path\\to\\executable.exe /argument" in
try
  while true do
    let line = input_line ch in …
  done
with End_of_file ->
  let status = close_process_in ch in …

请看一下有关
Unix
模块的手册。或
Sys.command
用于最简单的情况
let ch = Unix.open_process_in "c:\\path\\to\\executable.exe /argument" in
try
  while true do
    let line = input_line ch in …
  done
with End_of_file ->
  let status = close_process_in ch in …