Bohl's Blog

my digital life

no trouble with GetCommandLineW...

...but with VisualStudio. I put together a little test

int _tmain(int argc, _TCHAR* argv[])
    for (int i=0;i<argc;++i)

    LPCWSTR szCmdLine = GetCommandLineW();

	return 0;

and ran it in VisualStudio with this commandline: 

 and the result is:


It doesn't matter whether it is built as a Unicode-character-set project or Multibyte-character set - the result is the same.

Well, if we run the application from good old cmd.exe, we get:


 So, it seems that VisualStudio is interpreting the percent sign - a % followed by two hex digits becomes a single character (with the ASCII-value of this two-digit-hex). A percent sign on its own or followed by a non-hex-digit is not interpreted it seems.

So, what can we do it we want to have something like %0d on the commandline? Easy, just type %250d (0x25 is the ASCII value of %).

BTW - in a .bat file one has to escape the % by another %, our example %0d now reads %%0d. 

Kommentar schreiben