小编soc*_*nho的帖子

使用Win32执行命令

我想执行 shell 命令来更新我的处理器 ATMega 2560 的固件,如下所示:

avrdude.exe -c breakout -P ft0 -p m2560 -U flash:w:\"file.cpp.hex\":a
Run Code Online (Sandbox Code Playgroud)

我可以通过 ShellExecute() 函数来做到这一点:

ShellExecute(0, L"open", L"cmd.exe", L"/C avrdude.exe -c breakout -P ft0 -p     m2560 -U flash:w:\"file.cpp.hex\":a > log.txt", 0, SW_HIDE);
Run Code Online (Sandbox Code Playgroud)

但我想重定向输出缓冲区,所以我想我应该使用 CreateProcess() 函数。我尝试过这个,但没有成功。

CreateProcess(NULL, L"cmd /C avrdude.exe -c breakout -P ft0 -p m2560 -U flash:w:\"file.cpp.hex\":a", NULL, NULL, 0, 0, NULL, NULL, NULL, NULL);
Run Code Online (Sandbox Code Playgroud)

c++ winapi cmd createprocess

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

标签 统计

c++ ×1

cmd ×1

createprocess ×1

winapi ×1