The interpretation of command line parameters in the ide does not match the cmd interpretation:
This is the test code:
#define UNICODE
#define _UNICODE
#include <windows.h>
#include <wchar.h>
#include <stdio.h>
#include <shellapi.h>
int __cdecl wmain(void)
{
LPWSTR *szArglist;
int nArgs;
int i;
printf("%ls\n", GetCommandLineW());
szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);
if( NULL == szArglist )
{
wprintf(L"CommandLineToArgvW failed\n");
return 1;
}
else for( i=0; i<nArgs; i++) printf("[%d] [%ls]\n", i, szArglist[i]);
LocalFree(szArglist);
return(0);
}
This is a test call with 4 parameters.
D:\C\CMDLIN~1>cmdlinetst2 /1 "c:\pa\"th with blanks"\ /3 /4
The second parameter should have
a literal doublequote after the first 'a'. This has to be protected with the backslash
and
a backslash after the closing doublequote, to get a literal backslash at the parameters end.
If I execute this from CMD, I get:
cmdlinetst2 /1 "c:\pa\"th with blanks"\ /3 /4
[0] [cmdlinetst2]
[1] [/1]
[2] [c:\pa"th with blanks\]
[3] [/3]
[4] [/4]
This is exactly what I want!
From Pelles IDE I get:
D:\C\cmdlinetst\cmdlinetst2.exe /1 "c:\pa"th with blanks\" /3 /4
[0] [D:\C\cmdlinetst\cmdlinetst2.exe]
[1] [/1]
[2] [c:\path]
[3] [with]
[4] [blanks"]
[5] [/3]
[6] [/4]
The return value from GetCommandLineW() is not any more the real command line.
The \" is replaced by a single " and the "\ is turned to an \".
czerny