隐藏由 WinAPI 调用创建的 window

Hide window created by WinAPI call

我正在尝试从 C++ 代码调用 GhostScript(GS) 命令行工具。不幸的是,GS 创建了带有进度条的 window。我想知道有没有办法隐藏这个 window?下面列出的代码。如有任何建议,我将不胜感激。

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);

文档中,查看第 10.2 节支持的选项(设备属性)下的here

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.