如何在 Linux/Apache 虚拟主机上运行 win32 控制台应用程序?

How to run a win32 console application on Linux/Apache web-hosting?

本文关键字:win32 运行 控制台 应用程序 虚拟主机 Linux Apache      更新时间:2023-10-16

可执行文件使用2个非托管dll并在控制台上提供输出。 我目前正在XAMPP/localhost(在我的PC上(上运行它,并使用PHP的Exec((/PassThru((函数获取控制台输出。

它会在典型的基于 Apache/Linux 的 Web 托管帐户上运行吗?如果没有,我该怎么办?

在 PHP 中:

<?php
exec("TradeLogin.exe",$output);
//TradeLogin.exe is the win32-console-app, 
//situated at Xampp/htdocs, with couple of supporting binary files & dlls 
//(compiled on Visual-Studio-2015)
echo $output[0]."<br/>";
echo $output[1]."<br/>";
?>

我不知道它是否会有权限问题(我在 Windows 自动取款机上,所以不能尝试。

如果你想让它以这种方式运行,你需要一个Windows模拟器(例如Wine(,并像

exec("wine TradeLogin.exe 2>&1",$output);

或者可能需要完整路径。请注意,PHP 代码的执行将停止,直到程序完成运行。