The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

Ow, I'm too safe!
Aug 18, 2011
Post comments count 0
Post likes count 0

Ow, I'm too safe!

Raymond Chen
Raymond Chen

One of my friends is a geek, and, naturally, fully researches everything he does, from cement pouring to bicycle parts, perhaps a bit obsessively. He made sure to get five-point restraints for his children's car seats, for example. And he naturally tightens the belts snugly when putting his children in the car. At one point, as he was strapping his daughter in, she complained, "Ow! I'm too safe!" Because as far as she was concerned, "being safe" was a synonym for "having a tight seat belt." I leave you to figure out how she came to this conclusion.

Why does IFileOperation skip junctions even though I passed FOFX_NOSKIPJUNCTIONS?
Aug 18, 2011
Post comments count 0
Post likes count 0

Why does IFileOperation skip junctions even though I passed FOFX_NOSKIPJUNCTIONS?

Raymond Chen
Raymond Chen

The method accepts a number of flags to modify the file operation, among them today's subject . A customer reported that they couldn't get this flag to work: Whether they set it or not, the skipped over file system junctions. The term junction evolved two independent different meanings. The shell team invented the term shell namespace junction in Windows 95 to refer to a point in the shell namespace in which one type of namespace extension is grafted into another. For example, a directory of the form serves as the transition point between the default file system namespace and a custom namespace. Meanw...

Starting up inside the box
Aug 17, 2011
Post comments count 0
Post likes count 0

Starting up inside the box

Raymond Chen
Raymond Chen

the shell team received two customer questions about a month apart which seemed unrelated but had the same root cause. I found that in Windows Vista, the command is ten times slower than it was in Windows XP. What is the source of this slowdown, and how can I fix it? We have an application which takes a very long time to start up on Windows Vista than it did in Windows XP. We noticed that the slowdown occurs only if we set the application to autostart. Let's look at the second one first, since that customer provided a useful piece of information: The slowdown occurs only if they set the progr...

Why does creating a shortcut to a file change its last-modified time… sometimes?
Aug 16, 2011
Post comments count 0
Post likes count 0

Why does creating a shortcut to a file change its last-modified time… sometimes?

Raymond Chen
Raymond Chen

A customer observed that sometimes, the last-modified timestamp on a file would change even though nobody modified the file, or at least consciously took any steps to modify the file. In particular, they found that simply double-clicking the file in Explorer was enough to trigger the file modification. It took a while to puzzle out, but here's what's going on: When you double-click a file in Explorer, Explorer adds it to the Recent Items list. Internally, this is done by creating a shortcut to the item. The nice thing about a shortcut is that it knows how to track its target. That way, if you move an item, the...

Why does the runas command require its command line to be quoted?
Aug 15, 2011
Post comments count 0
Post likes count 1

Why does the runas command require its command line to be quoted?

Raymond Chen
Raymond Chen

Commenter teo complained that the command requires its command line to be quoted. Well, if you think about it, why single out ? Pretty much all programs require their command line to be quoted if they contain special characters (like spaces that you want to be interpreted as part of a file name instead of as an argument separator). The command is just doing things the way everybody else does. Recall that on Windows, programs perform their own command line parsing. This isn't unix where the command shell does the work of parsing quotation marks and globs before handing the (now-partly-parsed) command line to ...

ReadDirectoryChangesW reads directory changes, but what if the directory doesn’t change?
Aug 12, 2011
Post comments count 0
Post likes count 1

ReadDirectoryChangesW reads directory changes, but what if the directory doesn’t change?

Raymond Chen
Raymond Chen

Not all changes within a directory result in the directory changing.

The ways people mess up IUnknown::QueryInterface, episode 4
Aug 11, 2011
Post comments count 0
Post likes count 0

The ways people mess up IUnknown::QueryInterface, episode 4

Raymond Chen
Raymond Chen

One of the rules for is so obvious that nobody even bothers to state it explicitly as a rule: "If somebody asks you for an interface, and you return , then the pointer you return must point to the interface the caller requested." (This feels like the software version of dumb warning labels.) During compatibility testing for Windows Vista, we found a shell extension that behaved rather strangely. Eventually, the problem was traced to a broken implementation which depended subtly on the order in which interfaces were queried. The shell asked for the and interfaces in the following order: One parti...

Slim reader/writer locks don't remember who the owners are, so you'll have to find them some other way
Aug 10, 2011
Post comments count 0
Post likes count 0

Slim reader/writer locks don't remember who the owners are, so you'll have to find them some other way

Raymond Chen
Raymond Chen

The slim reader/writer lock is a very convenient synchronization facility, but one of the downsides is that it doesn't keep track of who the current owners are. When your thread is stuck waiting to acquire a slim reader/writer lock, a natural thing to want to know is which threads own the resource your stuck thread waiting for. Since there's not facility for going from the waiting thread to the owning threads, you'll just have to find the owning threads some other way. Here's the thread that is waiting for the lock in shared mode: Okay, how do you find the thread that owns the lock? First, slim reader/wr...

Why does the Shift+F10 menu differ from the right-click menu?
Aug 9, 2011
Post comments count 0
Post likes count 0

Why does the Shift+F10 menu differ from the right-click menu?

Raymond Chen
Raymond Chen

The Shift+F10 key is a keyboard shortcut for calling up the context menu on the selected item. but if you look closely, you might discover that the right-click menu and the Shift+F10 menu differ in subtle ways. Shouldn't they be the same? After all, that's the point of being a keyboard shortcut, right? Let's set aside the possibility that a program might be intentionally making them different, in violation of UI guidelines. For example, a poorly-designed program might use the message as the trigger to display the context menu instead of using the message, in which case Shift+F10 won't do anything at all. Or t...