0

I am spawning a child console process (zip.exe) from an MFC application

static TCHAR  s_atchZipTool[] = _T("\\tools\\zip.exe");
sArgZip.Format(_T("%s%s -e -r %s *.*"), GetAppPath(), s_atchZipTool, sFilePathName);
if( !CreateProcess(NULL, (LPTSTR)(LPCTSTR) sArgZip, NULL, NULL, 
                    FALSE, CREATE_NO_WINDOW, NULL, sFilesPath, &si, &pi) ) 
{
    return ::GetLastError();
}
else
{
    ::WaitForSingleObject( pi.hProcess, INFINITE );
}
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);

So when I do not need to set password for zipped file everything is fine, but how can I send multiple messages as console input to this process? Parameter -e forces me to put 2 more strings "Enter password", "Verify password".

Werner Henze
  • 16,404
  • 12
  • 44
  • 69
Finchsize
  • 935
  • 2
  • 17
  • 34
  • It's a lot of work, see [here](https://msdn.microsoft.com/en-us/library/windows/desktop/ms682499(v=vs.85).aspx). I don't know what you're up to, but from the smell of it, I'd think it a job for Python, not C++/MFC. – Jonas Byström Oct 08 '15 at 09:25
  • 1
    Use 7zip instead. It allows to set encryption password through the command line. – Ari0nhh Oct 08 '15 at 09:30
  • @Ari0nhh Thats not an answer, anyway it solve the problem. Thanks – Finchsize Oct 14 '15 at 11:22
  • Possible duplicate of [Import nested classes into namespace - C++](http://stackoverflow.com/questions/11647376/import-nested-classes-into-namespace-c) – Werner Henze Nov 18 '15 at 15:43

0 Answers0