假设一个标准配置,答案是否定的,它不是要求。您可以将该批处理文件包含在lpCommandLine
参数中。其余的参数只是在需要的地方用引号引用批处理文件。
TEST.CMD
@echo off
setlocal enableextensions disabledelayedexpansion
echo %1
echo %~1
echo %2
echo %~2
test.c的
#define _WIN32_WINNT 0x0500
#include <windows.h>
void main(void){
// Spawn process variables
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
ZeroMemory(&pi, sizeof(pi));
CreateProcess(
NULL
, "\"test.cmd\" \"x=1 y=2\" \"x=3 y=4\""
, NULL
, NULL
, TRUE
, 0
, NULL
, NULL
, &si
, &pi
);
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
};
输出
W:\>test.exe
"x=1 y=2"
x=1 y=2
"x=3 y=4"
x=3 y=4