Windows 上的管道 |
|
c = "''some shell command''" -- e.g. 'dir'
readfrom("|" .. c) -- this part will alway fail in standard Windows compiled binary
print(read("*a"))
在 lua-l 上 David Burgess 写道
On VC6, Lua 4.0.1 from the project menu Goto - "Project/Settings" Tab - "C/C++" Select "All configurations" Edit field - "Preprocessor definitions" and paste at the end of the existing string (which should already have something like "WIN32,_CONSOLE,_MBCS") POPEN,popen=_popen,pclose=_pclose
也尝试过使用 lcc for Windows。
您可以在 Compiler->Settings 面板中添加 POPEN 到 #defines 中。
不过,`_popen` 存在一个问题。Win32 API 文档指出,它仅在控制台应用程序中有效,因此如果您已将 Lua 嵌入到 Windows 应用程序中,则会遇到问题。但是,有一个补丁 [1],并且已在 SciTE 中进行了测试(它还提供了一个“静默”版本的 `os.execute`)。