不可见的 EXE 文件,它将通过传递它自己的命令行参数循环运行 php-cgi.exe,可以很容易地编译为例如 ms-VCpp6 ( phpCgiExeLoop.exe ~28kb):
#include <windows.h>
#include <Shellapi.h>
#include "stdio.h"
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{ while (1)
{ SHELLEXECUTEINFO shExInfo = {0};
shExInfo.cbSize = sizeof(shExInfo);
shExInfo.fMask = SEE_MASK_NOCLOSEPROCESS; shExInfo.hwnd = 0;
shExInfo.lpVerb = "open"; // Operation to perform
shExInfo.lpFile = "php-cgi.exe"; // Application to start
shExInfo.lpParameters = lpCmdLine; // Additional parameters
shExInfo.lpDirectory = 0; shExInfo.nShow = SW_HIDE;
shExInfo.hInstApp = 0;
if (ShellExecuteEx(&shExInfo))
{ WaitForSingleObject(shExInfo.hProcess, INFINITE);
CloseHandle(shExInfo.hProcess);
}
}
return 0;
}
并运行“phpCgiExeLoop -b 127.0.0.1:9000”而不是“php-cgi.exe -b 127.0.0.1:9000”......以赢得支持 php 创建者的意图(避免可能的内存泄漏)。