小编G93*_*G93的帖子

通过 SHELLEXECUTEINFO 向 .exe 发送参数

我有一个需要 2 个参数的 .exe。我需要在运行时在我的程序之间运行 .exe 文件。我曾经ShellExecuteEx运行过 .exe 文件,但它没有接受参数。请帮助我哪里出错了。我在下面发布我的代码。

void StartProgram() {
    SHELLEXECUTEINFO lpExecInfo;
    lpExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
    lpExecInfo.lpFile = L"F:\\EXEFolder\\RunMe.exe"; // Path to the .exe
    lpExecInfo.fMask = SEE_MASK_DOENVSUBST | SEE_MASK_NOCLOSEPROCESS;
    lpExecInfo.hwnd = NULL;
    lpExecInfo.lpVerb = L"open"; // to open  program
    lpExecInfo.lpParameters = L"D:/input.csv" "F:/output.csv;"; //Arguments to be passed to .exe
    lpExecInfo.lpDirectory = NULL;
    lpExecInfo.nShow = SW_SHOW;
    lpExecInfo.hInstApp = (HINSTANCE)SE_ERR_DDEFAIL;   
    ShellExecuteEx(&lpExecInfo);
    //wait until a file is finished printing
    if (lpExecInfo.hProcess != NULL)
    {
        ::WaitForSingleObject(lpExecInfo.hProcess, INFINITE);
        ::CloseHandle(lpExecInfo.hProcess);
    }
}
Run Code Online (Sandbox Code Playgroud)

c c++ shellexecute runtime.exec shellexecuteex

1
推荐指数
1
解决办法
88
查看次数

标签 统计

c ×1

c++ ×1

runtime.exec ×1

shellexecute ×1

shellexecuteex ×1