The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

What does the CreateProcess function do if there is no space between the program name and the arguments?
Aug 8, 2011
Post comments count 0
Post likes count 0

What does the CreateProcess function do if there is no space between the program name and the arguments?

Raymond Chen
Raymond Chen

In an old discussion of why the function modifies its command line, commenter Random832 asked, "What if there is no space between the program name and arguments - like "cmd/?" - where does it put the null then?" The function requires a space between the program name and arguments. If you leave out the space, then the arguments are considered as part of the program name (and you'll almost certainly get back). It sounds like Random832 has confused command line parsing with command line parsing. Clearly the two parsers are different; you can see this even without playing with spaces between the program na...

Menu item states are not reliable until they are shown because they aren't needed until then
Aug 5, 2011
Post comments count 0
Post likes count 0

Menu item states are not reliable until they are shown because they aren't needed until then

Raymond Chen
Raymond Chen

A question arrived from a customer (with the rather unhelpful subject line Question for Microsoft) wondering why, when they call and then ask for the states of the various menu items like , the menu item states don't reflect reality. The menu item states don't synchronize with reality until the user actually opens the system menu. There is no requirement that applications keep menu item states continuously in sync. After all, that's why we have messages like : To tell the application, "Whoa, we're about to show this menu, so you might want to comb its hair and pick the food out of its teeth so it can be seen by...

Why doesn't b match word boundaries correctly?
Aug 4, 2011
Post comments count 0
Post likes count 0

Why doesn't b match word boundaries correctly?

Raymond Chen
Raymond Chen

A colleague of mine was having trouble getting the metacharacter in a regular expression to work. Of course, when somebody asks a question like that, you first have to establish what their definition of "work" is. Fortunately, he provided some examples: "The last two entries are just sanity checks to make sure I didn't make some stupid mistake like passing the parameters in the wrong order. I want to search for a string that contains %1 with word boundaries on either side, something I would normally use \b for. Is there something special about the % character? Notice that the match succeeds when I look for the...

A shell extension is a guest in someone else's house; don't go changing the code page
Aug 3, 2011
Post comments count 0
Post likes count 0

A shell extension is a guest in someone else's house; don't go changing the code page

Raymond Chen
Raymond Chen

A customer reported a problem with their shell extension: We want to format a floating point number according to the user's default locale. We do this by calling to convert the value from floating point to text with a period (U+002E) as the decimal separator, then using to apply the user's preferred grouping character, decimal separator, etc. We found, however, that if the user is running in (say) German, we find that sometimes (but not always) the function follows the German locale and uses a comma (U+002C) as the decimal separator with no thousands separator. This format prevents the function from working...

An even easier way to get Windows Media Player to single-step a video
Aug 2, 2011
Post comments count 0
Post likes count 0

An even easier way to get Windows Media Player to single-step a video

Raymond Chen
Raymond Chen

Since my original article explaining how to get Windows Media Player to single-step a video, I've learned that there's an even easier way. Backward-stepping is dependent upon the codec; some of them will go backward to the previous keyframe. The person who tipped me off to this feature: The developer who implemented it. Remember: Sharing a tip does not imply that I approve of the situation that led to the need for the tip in the first place.

Microspeak: Dogfood
Aug 2, 2011
Post comments count 0
Post likes count 2

Microspeak: Dogfood

Raymond Chen
Raymond Chen

The shifting meaning.

Why can you set each monitor to a different color depth?
Aug 1, 2011
Post comments count 0
Post likes count 1

Why can you set each monitor to a different color depth?

Raymond Chen
Raymond Chen

Random832 seemed horrified by the fact that it is possible to run multiple monitors, with different color formats on each monitor. "Seriously, why does it let you do that?" Well, of course you can do that. Why shouldn't it let you do that? When multiple monitors were introduced to Windows, video hardware was nowhere near as advanced as it is today. One common discovery was that your computer, which came with a video card in one of the expansion slots, actually had a video chip baked into the motherboard, but which was disabled in the BIOS. In other words, your computer was actually multiple-monitor-capable; it'...

Hey, let's report errors only when nothing is at stake!
Jul 29, 2011
Post comments count 0
Post likes count 0

Hey, let's report errors only when nothing is at stake!

Raymond Chen
Raymond Chen

Only an idiot would have parameter validation, and only an idiot would not have it. In an attempt to resolve this paradox, commenter Gabe suggested, "When running for your QA department, it should crash immediately; when running for your customer, it should silently keep going." A similar opinion was expressed by commenter Koro and some others. This replaces one paradox with another. Under the new regime, your program reports errors only when nothing is at stake. "Report problems when running in test mode, and ignore problems when running on live data." Isn't this backwards? Shouldn't we be more sensitive to p...

Simulating input via WM_CHAR messages may fake out the recipient but it won't fake out the input system
Jul 28, 2011
Post comments count 0
Post likes count 0

Simulating input via WM_CHAR messages may fake out the recipient but it won't fake out the input system

Raymond Chen
Raymond Chen

We saw some time ago that you can't simulate keyboard input with . You may get away with it, depending on how the application you're trying to fake out processes input, but since you're just faking data, the application may discover that it's all a ruse when they try to access information that you didn't fake out, say by calling and discovering that the key it was told was being pressed is in fact not being pressed after all. When you try to do this fake-out, you might or might not be able to fake out the application, but you're definitely not going to fake out the input system itself. I wrote a test program ...