[Bf-committers] system() with spaces

Tony Agee tonyagee at cox.net
Sun Nov 19 01:16:05 CET 2006


After digging into it some more, it makes no sense at all. Your code below
seems as though it should just work!!
But this does:

#include <windows.h>
#include <stdio.h>
#include <tchar.h>

void _tmain( VOID )
{
    STARTUPINFO si;
    PROCESS_INFORMATION pi;
    LPTSTR szCmdline=_tcsdup(TEXT("\"C:\\Program Files\\Blender
Foundation\\Blender\\blender.exe\" -a \"c:\\tmp\\0001_0020.avi\""));

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

    // Start the child process.
    if( !CreateProcess( NULL,   // No module name (use command line)
        szCmdline,      // 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
    )
    {
        printf( "CreateProcess failed (%d).\n", GetLastError() );
        return;
    }

    // Wait until child process exits.
    WaitForSingleObject( pi.hProcess, INFINITE );

    // Close process and thread handles.
    CloseHandle( pi.hProcess );
    CloseHandle( pi.hThread );
}


-----Original Message-----
From: bf-committers-bounces at projects.blender.org
[mailto:bf-committers-bounces at projects.blender.org] On Behalf Of Alexander
Ewering
Sent: Saturday, November 18, 2006 4:05 PM
To: bf-blender developers
Subject: RE: [Bf-committers] system() with spaces


On Sat, 18 Nov 2006, Tony Agee wrote:

> And it doesn't work for me either, but I observe that the error on the
> console after a failure in blender, is the same as the error I get when I
> run (from a command prompt):
>
> "C:/Program Files/Blender Foundation/Blender/blender.exe -a
> c:\tmp\0001_0020.avi"

Well, this looks totally wrong, of course. What we're trying to tell the
system is:

"This is a path to an executable which may contain spaces" -switch1 \
-switch2 -switch3 "This is a path to a movie which may contain spaces"

And this is the code that generates the line:

sprintf(str, "\"%s\" -a -p %d %d \"%s\"", bprogname, pos[0], pos[1], file);

Unless I'm again totally blind and too sleep-deprived, this code generates
what I stated above, and should work (it does work on Linux). Why does it
not work on win32?

| alexander ewering              instinctive mediaworks
| xx-mail.com/instinctive     http://www.instinctive.de
_______________________________________________
Bf-committers mailing list
Bf-committers at projects.blender.org
http://projects.blender.org/mailman/listinfo/bf-committers



More information about the Bf-committers mailing list