gpt4 book ai didi

c++ - 从 win32 应用程序运行外部 exe

转载 作者:可可西里 更新时间:2023-11-01 14:44:00 26 4
gpt4 key购买 nike

我正在 Visual Studio 2010 中开发 WIN32 应用程序。我必须从我的代码中执行一个外部 exe,但不必显示它的窗口。在执行 exe 的同时,我将某些参数传递给 exe。给出了我的代码

char path[] = "D:\\scan\\scan.exe -l";
system(path);
//ShellExecute(hWnd, "open",path, NULL, NULL, SWP_HIDEWINDOW);

如果我使用 system(path) 它会正确执行,但也会显示 exe 的窗口,但如果我使用 ShellExecute(hWnd, "open",path, NULL, NULL, SWP_HIDEWINDOW);然后不执行给定路径的exe。我该如何克服这个问题,请指导我

最佳答案

ShellExecute希望程序名称及其参数分别给出。试试这个:

ShellExecute(hWnd, NULL, "D:\\scan\\scan.exe", "-l", NULL, SW_HIDE);

关于c++ - 从 win32 应用程序运行外部 exe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19154516/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com