I need to create a variable to use in the CreateProcess:
CreateProcess(z7Cmdline, z7Arg, NULL, NULL, FALSE, NULL, NULL, NULL, &startInfo, &processInfo);
The variable z7Arg is a argument list for 7 -zip which contains a file name based on the current date ie: 2017-12-13.zip.
string buArg = "-o""c:\\moshe"" a " + buDir + buFileName + "c:\\moshe\\*.pdf";
I want to copy buArg into z7Arg as a LPTSTR to use in the CreateProcess routine
How do I go about it?
I am new at coding in C++, 30 years ago I programed in IBM Fortran & Assembly language for Grumman Aerospace, but have done little coding since then.
You have to do 2 things:
const char*toconst TCHAR*, whereTCHARmay be eithercharorwchar_tdepending on whether Unicode is enabled for your project.constbecauseCreateProcessrequiresTCHAR*, notconst TCHAR*. You can't just useconst_cast, you need a writable buffer that you'll pass toCreateProcess.For that you may use convenient string conversion macros from ATL or MFC. Use it the following way:
or just
Read more about string conversion macros here.
If you don't have access to ATL or MFC in your project and you have Unicode enabled, you'll need to manually convert
char*towchar_t*usingMultibyteToWideChar.