Skip to content

Commit 45339c0

Browse files
author
전상현
committed
[100_System] 윈도우 ShellExecuteByPipe 함수에서 한글이 포함된 출력문이 있을 경우 간혹 글자가 깨지는 문제 수정
1 parent 51c6ed3 commit 45339c0

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Src/100_System/KernelObjectT_Win.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,21 +254,21 @@ namespace core
254254
}
255255

256256
//////////////////////////////////////////////////////////////////////////
257-
static void ReadContextFromPipe(HANDLE hStdOut, std::tstring& strOutput)
257+
static void ReadContextFromPipe(HANDLE hStdOut, std::string& strOutput)
258258
{
259259
DWORD dwAvail = 0;
260260
while (::PeekNamedPipe(hStdOut, NULL, 0, NULL, &dwAvail, NULL))
261261
{
262262
if (0 == dwAvail)
263-
return;
263+
break;
264264

265265
const DWORD dwBuffSize = 32;
266266
char szBuffer[dwBuffSize + 1];
267267

268268
DWORD dwReadSize = 0;
269269
ReadFile(hStdOut, szBuffer, MIN(dwAvail, dwBuffSize), &dwReadSize);
270270
szBuffer[dwReadSize] = 0;
271-
strOutput += TCSFromMBS(szBuffer);
271+
strOutput += szBuffer;
272272
}
273273
}
274274

@@ -305,9 +305,11 @@ namespace core
305305
if (!::CreateProcess(NULL, (LPTSTR)strCmdLine.c_str(), NULL, NULL, TRUE, 0, NULL, NULL, &stStartupInfo, &stProcessInfo))
306306
throw exception_format(TEXT("Failed to CreateProcess(%s)"), strCmdLine.c_str());
307307

308+
std::string strTempOutput;
308309
while (WAIT_TIMEOUT == ::WaitForSingleObject(stProcessInfo.hProcess, 100))
309-
ReadContextFromPipe(hStdOutPair[0], strOutput);
310-
ReadContextFromPipe(hStdOutPair[0], strOutput);
310+
ReadContextFromPipe(hStdOutPair[0], strTempOutput);
311+
ReadContextFromPipe(hStdOutPair[0], strTempOutput);
312+
strOutput = TCSFromMBS(strTempOutput);
311313

312314
if (!GetExitCodeProcess(stProcessInfo.hProcess, &dwExitCode))
313315
Log_Warn(TEXT("GetExitCodeProcess failure."));

0 commit comments

Comments
 (0)