Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using CreateProcess with a relative path

Is it possible to pass a relative path to create my child process? This code will compile, but it gives an error because I'm using a relative path.

void Cminivideo3App::creerChildProcess(void)
{
    STARTUPINFO si;
    PROCESS_INFORMATION pi;

    ZeroMemory( &si, sizeof(si) );
    si.cb = sizeof(si);
    ZeroMemory( &pi, sizeof(pi) );

    // Start the child process. 
  int retvalue =   CreateProcess( TEXT("\..\Debug\traitement.exe"),   // No module name (use command line)
        NULL,        // Command line
        NULL,           // Process handle not inheritable
        NULL,           // Thread handle not inheritable
        FALSE,          // Set handle inheritance to FALSE
        0,              // No creation flags
        NULL,           // Use parent's environment block
        NULL,           // Use parent's starting directory 
        &si,            // Pointer to STARTUPINFO structure
        &pi            // Pointer to PROCESS_INFORMATION structure
    );

  int lastError = GetLastError();


}
like image 949
toto Avatar asked Jun 27 '26 07:06

toto


1 Answers

Couple things:

  1. As @Oswald says, \ is the root folder of the current drive, not a relative path.
  2. You forgot to escape your backslashes. You really want TEXT("..\\Debug\\traitement.exe").
like image 161
Billy ONeal Avatar answered Jun 28 '26 20:06

Billy ONeal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!