我正在尝试从 C++ 代码调用 GhostScript(GS) 命令行工具。不幸的是,GS 创建了带有进度条的窗口。我想知道有没有办法隐藏这个窗口?下面列出的代码。如果有任何建议,我将不胜感激。
std::string cmd = ("gswin32c.exe -sDEVICE=mswinpr2 -dBATCH -dNOPAUSE -dNOSAFER -sOutputFile=\"%printer%HPLJ2000\" \"1.pdf\"");
SECURITY_ATTRIBUTES sa;
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.lpSecurityDescriptor = NULL;
sa.bInheritHandle = TRUE;
auto dwFlags = FILE_ATTRIBUTE_NORMAL;
STARTUPINFOW si;
GetStartupInfoW(&si);
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE;
ZeroMemory(&pi, sizeof(pi));
if (!CreateProcess(NULL, cmd.c_str(), NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi)) {
std::err << "Something went wrong" << std::endl;
}
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
最佳答案
它在文档中,看here在第 10.2 节支持的选项(设备属性)下
The following options are available:
/NoCancel boolean Disables (hides) the progress dialog when set to true or show the progress dialog if not set or set to false.
关于c++ - 隐藏由 WinAPI 调用创建的窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51972827/