Discussion:
System("..") without flicker
(too old to reply)
Jonathan de Boyne Pollard
2010-05-10 15:08:59 UTC
Permalink
The compiler uses stdout/stderr, which causes a console window to be
created [...]
No. What causes the console window to be created is that the command
interpreter that %COMSPEC% points to is marked as a Windows Character
Mode executable. It cannot be determined ahead of time, i.e. before the
program is launched into a child process, whether a program will use its
standard handles. But the subsystem field in the PE header is available
ahead of time, and that is what is used to determine whether the child
process has a console.
Franz Bachler
2010-06-03 13:47:27 UTC
Permalink
Hello all,

the solution is CreateProcess, this doesn't flicker under the NT-Line but it
flickers under 9x. Under 9x WinExec works but WinExec doesn't wait until the
subprocess terminated. Here helps only Sleep() with sufficient delay.

Greetings,
Franz

{
STARTUPINFO si;
PROCESS_INFORMATION pi;
OSVERSIONINFO osvi;
BOOL bS=FALSE;
TCHAR szCommand=TEXT("dosprog argument");

ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&osvi);

ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);

// Start the child process.
if (osvi.dwMajorVersion>=5)
{
bS=CreateProcess
(
NULL, // No module name (use command line)
szCommand, // Command line
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
FALSE, // Set handle inheritance to FALSE
CREATE_NO_WINDOW, // Creation flags
NULL, // Use parent's environment block
NULL, // Use parent's starting directory
&si, // Pointer to STARTUPINFO structure
&pi // Pointer to PROCESS_INFORMATION structure
);
}

if (bS)
{
WaitForSingleObject(pi.hProcess, INFINITE);

// Close process and thread handles.
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
}
else
{
WinExec(szHelp, SW_HIDE);
Sleep(650);
}
}

Loading...