diff options
author | Jeffrey Armstrong <jeffrey.armstrong@approximatrix.com> | 2021-10-04 11:59:26 -0400 |
---|---|---|
committer | Jeffrey Armstrong <jeffrey.armstrong@approximatrix.com> | 2021-10-04 11:59:26 -0400 |
commit | 7fe31126d121e810dd93641ae6582e9ab1dac16e (patch) | |
tree | b41b7b7de464d23d803d7a89b2250c3327545524 /ProcessUtils.cpp | |
parent | 7f2c8e1885f8e0cc74a3de206c8cf564b7b54124 (diff) | |
download | RadTerminal-7fe31126d121e810dd93641ae6582e9ab1dac16e.tar.gz RadTerminal-7fe31126d121e810dd93641ae6582e9ab1dac16e.zip |
Added ability to specify a working directory on opening a terminal. Released memory on calls using the ANSI creation function.
Diffstat (limited to 'ProcessUtils.cpp')
-rw-r--r-- | ProcessUtils.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/ProcessUtils.cpp b/ProcessUtils.cpp index e3effc9..efafc00 100644 --- a/ProcessUtils.cpp +++ b/ProcessUtils.cpp @@ -16,7 +16,7 @@ namespace { spd->hPC = NULL; } - SubProcessData CreateSubProcess(LPCTSTR cmd, COORD size, HANDLE hInput, HANDLE hOutput, bool bUseConPty) + SubProcessData CreateSubProcess(LPCTSTR cmd, LPCTSTR wdir, COORD size, HANDLE hInput, HANDLE hOutput, bool bUseConPty) { SubProcessData spd = {}; @@ -87,8 +87,11 @@ namespace { } TCHAR localcmd[MAX_PATH]; + TCHAR localwdir[MAX_PATH]; _tcscpy_s(localcmd, cmd); - if (!CreateProcess(nullptr, localcmd, nullptr, nullptr, bInheritHandles, dwCreationFlags, nullptr, nullptr, &si.StartupInfo, &spd.pi)) + if(wdir != nullptr) + _tcscpy_s(localwdir, wdir); + if (!CreateProcess(nullptr, localcmd, nullptr, nullptr, bInheritHandles, dwCreationFlags, nullptr, wdir == nullptr ? nullptr : localwdir, &si.StartupInfo, &spd.pi)) { spd.hr = HRESULT_FROM_WIN32(GetLastError()); CleanupSubProcess(&spd); @@ -101,7 +104,7 @@ namespace { } } -SubProcessData CreateSubProcess(LPCTSTR cmd, COORD size, bool bUseConPty) +SubProcessData CreateSubProcess(LPCTSTR cmd, LPCTSTR wdir, COORD size, bool bUseConPty) { SubProcessData spd = {}; @@ -119,7 +122,7 @@ SubProcessData CreateSubProcess(LPCTSTR cmd, COORD size, bool bUseConPty) spd.hr = HRESULT_FROM_WIN32(GetLastError()); if (spd.hr == S_OK) - spd = CreateSubProcess(cmd, size, hReadPipeInput, hWritePipeOutput, bUseConPty); + spd = CreateSubProcess(cmd, wdir, size, hReadPipeInput, hWritePipeOutput, bUseConPty); if (spd.hr == S_OK) { |