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. 

trouble with GetCommandLineW

I noticed that ffmpeg has changed the handling of command line arguments (cf. release notes). It now uses GetCommandLineW - in order to get unicode text (e.g. for filenames), which is a good thing I guess. However, at least for me I cannot pass a percent sign ("%") on the command line any more, e.g. something like

winffmpeg -i test.avi image%5d.jpg


What I get from GetCommandLineW in this case is

 "S:\SVN\WINFFMPEG\Build\Debug\winffmpeg.exe" winffmpeg -i test.avi image].jpg


...which is not what I would expect.

I read through the insightfull articel here - but it does not mention that the precent sign is interpreted in some way.

Well, funny and I do not get it.

My first idea is to turn the exe into a unicode project - could this save us all this kind of trouble?

burn out?

Johann König's Burnout-Song (in German) - my favorite :

Upps, the video has been removed... Another try: