mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-06 07:57:22 +00:00
wineconsole: Set launched process name as created console title.
wineconsole was setting created console's title to '????\wineconsole.exe'. This was preventing conhost to load its configuration according to first running command path. Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
This commit is contained in:
parent
b8b55de629
commit
cd0e949519
|
@ -41,36 +41,38 @@ int WINAPI wWinMain( HINSTANCE inst, HINSTANCE prev, WCHAR *cmdline, INT show )
|
||||||
|
|
||||||
static WCHAR default_cmd[] = L"cmd";
|
static WCHAR default_cmd[] = L"cmd";
|
||||||
|
|
||||||
FreeConsole(); /* make sure we're not connected to inherited console */
|
if (!*cmd) cmd = default_cmd;
|
||||||
|
|
||||||
|
if (!CreateProcessW( NULL, cmd, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &startup, &info ))
|
||||||
|
{
|
||||||
|
HANDLE hStdInput, hStdOutput;
|
||||||
|
WCHAR format[256], *buf;
|
||||||
|
INPUT_RECORD ir;
|
||||||
|
DWORD len;
|
||||||
|
|
||||||
|
exit_code = GetLastError();
|
||||||
|
WARN( "CreateProcess '%ls' failed: %lu\n", cmd, exit_code );
|
||||||
|
|
||||||
|
/* create a new console to display error messages in it */
|
||||||
|
FreeConsole(); /* make sure we're not connected to any console */
|
||||||
if (!AllocConsole())
|
if (!AllocConsole())
|
||||||
{
|
{
|
||||||
ERR( "failed to allocate console: %lu\n", GetLastError() );
|
ERR( "failed to allocate console: %lu\n", GetLastError() );
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!*cmd) cmd = default_cmd;
|
hStdInput = CreateFileW( L"CONIN$", GENERIC_READ | GENERIC_WRITE, 0, NULL,
|
||||||
|
|
||||||
startup.dwFlags = STARTF_USESTDHANDLES;
|
|
||||||
startup.hStdInput = CreateFileW( L"CONIN$", GENERIC_READ | GENERIC_WRITE, 0, NULL,
|
|
||||||
OPEN_EXISTING, 0, 0 );
|
OPEN_EXISTING, 0, 0 );
|
||||||
startup.hStdOutput = CreateFileW( L"CONOUT$", GENERIC_READ | GENERIC_WRITE, 0, NULL,
|
hStdOutput = CreateFileW( L"CONOUT$", GENERIC_READ | GENERIC_WRITE, 0, NULL,
|
||||||
OPEN_EXISTING, 0, 0 );
|
OPEN_EXISTING, 0, 0 );
|
||||||
startup.hStdError = startup.hStdOutput;
|
|
||||||
|
|
||||||
if (!CreateProcessW( NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &info ))
|
|
||||||
{
|
|
||||||
WCHAR format[256], *buf;
|
|
||||||
INPUT_RECORD ir;
|
|
||||||
DWORD len;
|
|
||||||
exit_code = GetLastError();
|
|
||||||
WARN( "CreateProcess failed: %lu\n", exit_code );
|
|
||||||
LoadStringW( GetModuleHandleW( NULL ), IDS_CMD_LAUNCH_FAILED, format, ARRAY_SIZE(format) );
|
LoadStringW( GetModuleHandleW( NULL ), IDS_CMD_LAUNCH_FAILED, format, ARRAY_SIZE(format) );
|
||||||
len = wcslen( format ) + wcslen( cmd );
|
len = wcslen( format ) + wcslen( cmd );
|
||||||
if ((buf = malloc( len * sizeof(WCHAR) )))
|
if ((buf = malloc( len * sizeof(WCHAR) )))
|
||||||
{
|
{
|
||||||
swprintf( buf, len, format, cmd );
|
swprintf( buf, len, format, cmd );
|
||||||
WriteConsoleW( startup.hStdOutput, buf, wcslen(buf), &len, NULL);
|
WriteConsoleW( hStdOutput, buf, wcslen(buf), &len, NULL);
|
||||||
while (ReadConsoleInputW( startup.hStdInput, &ir, 1, &len ) && ir.EventType == MOUSE_EVENT);
|
while (ReadConsoleInputW( hStdInput, &ir, 1, &len ) && ir.EventType == MOUSE_EVENT);
|
||||||
}
|
}
|
||||||
return exit_code;
|
return exit_code;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue