From be3b47d0d504a3409ce66bd77bb8c0acff87c4f5 Mon Sep 17 00:00:00 2001 From: kh1 Date: Thu, 15 Mar 2012 14:53:47 +0100 Subject: Reorganize the tree, have better ifw.pri. Shadow build support. Change-Id: I01fb12537f863ed0744979973c7e4153889cc5cb Reviewed-by: Tim Jenssen --- src/libs/7zip/win/CPP/Windows/Process.cpp | 81 +++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 src/libs/7zip/win/CPP/Windows/Process.cpp (limited to 'src/libs/7zip/win/CPP/Windows/Process.cpp') diff --git a/src/libs/7zip/win/CPP/Windows/Process.cpp b/src/libs/7zip/win/CPP/Windows/Process.cpp new file mode 100644 index 000000000..9bcee7d5a --- /dev/null +++ b/src/libs/7zip/win/CPP/Windows/Process.cpp @@ -0,0 +1,81 @@ +// Process.cpp + +#include "StdAfx.h" + +#include "../Common/StringConvert.h" + +#include "Process.h" + +#ifndef _UNICODE +extern bool g_IsNT; +#endif + +namespace NWindows { + +static UString GetQuotedString(const UString &s) +{ + return UString(L'\"') + s + UString(L'\"'); +} + +WRes CProcess::Create(LPCWSTR imageName, const UString ¶ms, LPCWSTR curDir) +{ + Close(); + const UString params2 = + #ifndef UNDER_CE + GetQuotedString(imageName) + L' ' + + #endif + params; + #ifdef UNDER_CE + curDir = 0; + #else + imageName = 0; + #endif + PROCESS_INFORMATION pi; + BOOL result; + #ifndef _UNICODE + if (!g_IsNT) + { + STARTUPINFOA si; + si.cb = sizeof(si); + si.lpReserved = 0; + si.lpDesktop = 0; + si.lpTitle = 0; + si.dwFlags = 0; + si.cbReserved2 = 0; + si.lpReserved2 = 0; + + CSysString curDirA; + if (curDir != 0) + curDirA = GetSystemString(curDir); + result = ::CreateProcessA(NULL, (LPSTR)(LPCSTR)GetSystemString(params2), + NULL, NULL, FALSE, 0, NULL, ((curDir != 0) ? (LPCSTR)curDirA: 0), &si, &pi); + } + else + #endif + { + STARTUPINFOW si; + si.cb = sizeof(si); + si.lpReserved = 0; + si.lpDesktop = 0; + si.lpTitle = 0; + si.dwFlags = 0; + si.cbReserved2 = 0; + si.lpReserved2 = 0; + + result = CreateProcessW(imageName, (LPWSTR)(LPCWSTR)params2, + NULL, NULL, FALSE, 0, NULL, (LPWSTR)curDir, &si, &pi); + } + if (result == 0) + return ::GetLastError(); + ::CloseHandle(pi.hThread); + _handle = pi.hProcess; + return 0; +} + +WRes MyCreateProcess(LPCWSTR imageName, const UString ¶ms) +{ + CProcess process; + return process.Create(imageName, params, 0); +} + +} -- cgit v1.2.3