2
I have an application, where the user uploads a file to the remote server, this same server when receiving this file should run this application. I’m using the Createprocess method. The problem is, the file directory is already set in an Std::string , and I’m having difficulty passing this directory as a parameter to Createprocess.
How should I proceed so that this directory can be passed to Createprocess without errors?
EDITING: Now the code compiles, but the file is not executed...
//o cliente envia remotamente o diretorio onde sera salvo o arquivo
socket_setup.SEND_BUFFER("\nDiretorio remoto para upload: ");
char *dirUP_REMOTE = socket_setup.READ_BUFFER();
std::string DIRETORIO_UP = dirUP_REMOTE; // variavel onde se armazena o diretorio remoto
//depois do upload essa é a validação para execução do arquivo
if (!strcmp(STRCMP_EXECUTE, EXECUTE_TIME_YES))
{
std::wstring temp(directory.begin(), directory.end());
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
ZeroMemory(&pi, sizeof(pi));
CreateProcess(NULL, (LPWSTR)temp.c_str(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
}
What difficulties you’re having?
– André Ribeiro
if (!Createprocess(NULL,/directory.c_str()/, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)); in this argument passage for the create process /directory.c_str()
– user17270
Yes, but what happens? Build or run error?
– André Ribeiro