1
Vote

Support Multiple Command-Line Arguments

description

The current implementation fails if the Process<n> string contains more than one command-line argument. The solution proposed here is actually a simplification of the current implementation:

Change this:
wcscpy(tcModuleName,ps->szName);

TCHAR *tcPtrSpace=wcsrchr(ps->szName,L' ');
if (NULL != tcPtrSpace) {
    tcModuleName[lstrlen(ps->szName)-lstrlen(tcPtrSpace)]=0x00;
    tcPtrSpace++; // move past space character.
}

CreateProcess( tcModuleName, // Module Name    
        tcPtrSpace,     // Command line -- NULL or PTR to command line
To this:
TCHAR *tcArguments=wcschr(ps->szName,L' ');
if (NULL != tcArguments) {
    *tcArguments++ = 0;
}
wcscpy(tcModuleName,ps->szName);

CreateProcess( tcModuleName, // Module Name    
        tcArguments,    // Command line -- NULL or PTR to command line
NB: Note the change of the reverse search 'wcsrchr' to a forward search 'wcschr'.

comments