The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

Feb 7, 2013
Post comments count 0
Post likes count 1

How can I register my context menu command for all file types *except* one, or other complex conditionals?

Raymond Chen

Advanced Query Syntax to the rescue.

Feb 6, 2013
Post comments count 0
Post likes count 1

The curious pattern of pre-emptively rejecting the solution to your problem

Raymond Chen

A frustrating pattern that shows up occasionally in customer questions is the case where the customer poses a problem, and pre-emptively rejects the mechanism explicitly designed to solve that problem. How can we change the widget color without using IWidget::Set­Color? Um, the whole point of IWidget::Set­Color is to change the color of a widget. Why are you rejecting the mechanism whose sole purpose in life is to solve the very problem you are having? Usually, if you press hard enough, they will cough up the reason why they think they cannot use the solution specifically designed to do what they w...

Feb 5, 2013
Post comments count 0
Post likes count 1

Optimizing the Chili’s dining experience

Raymond Chen

Back in the days of Windows 95, one of my colleagues paid a visit to his counterparts over in the Windows NT team as part of a continuing informal engagement to keep the Windows NT developers aware of the crazy stuff we've been doing on the Windows 95 side. One particular time, his visit occurred in late morning, and it ran longer than usual, so the Windows NT folks said, "Hey, it's lunchtime. Do you want to join us for lunch? It's sort of our tradition to go to Chili's for lunch on Thursdays." My colleague cheerfully accepted their offer. The group were shown to their table, a...

Feb 4, 2013
Post comments count 0
Post likes count 1

Old trace logs in your dreams

Raymond Chen

I dreamed that I was archiving old data. Some came off an old CP/M floppy disc. Another was an IntelliTrace debug log from the 1980's. Back then, IntelliTrace recorded the history onto index cards, which were stored in trays like in a library card catalog. Made jumping back and forth really easy, but setting breakpoints was a pain.

Feb 4, 2013
Post comments count 0
Post likes count 1

Obtaining the parsing name (and pidl) for a random shell object

Raymond Chen

The parsing name for a shell item is handy, because it lets you regenerate the item later. Actually, the pidl for the shell item is even better, because that is the official way of saving and restoring objects. It's the pidl that gets saved in a shortcut, and since shortcuts can be copied around from machine to machine, pidls must be transportable and forward compatible. (A shortcut file created on Windows XP needs to keep working on all future versions of Windows.) Here's a handy little tool for grabbing the parsing name and pidl for a random shell object. Start with our scratch program, and add in the ...

Feb 1, 2013
Post comments count 0
Post likes count 0

The annual sporting event involving a football that dare not speak its name and a digression into the sportsmanship of wasting time in nonproductive activity

Raymond Chen

I always wonder about people who are so protective of the name of their event that they don't even allow people to mention it by name. One of the most notorious examples is the organization which runs a major international gathering of athletes which takes place every four years (or every two years if you consider warm-weather sports and cold-weather sports). Another example is that you aren't allowed to refer to the championship game of the major professional American football league by its actual name without permission. You have to use some alternate phrasing like the big game. I propose that all media organi...

Feb 1, 2013
Post comments count 0
Post likes count 1

Psychic debugging: Why your IContextMenu::InvokeCommand doesn’t get called even though you returned success from IContextMenu::QueryContextMenu

Raymond Chen

A customer was having trouble with their IContext­Menu implementation. They observed that their IContext­Menu::Query­Context­Menu method was being called, but when the user selected their menu item, IContext­Menu::Invoke­Command was not being called. Given what you know about shell context menus, you can already direct the investigation. I'll let you read up about it first, especially the part about composition, then we can see how much you've learned. Welcome back. (Okay, I know you didn't actually do the reading, but I'm welcoming you back anyway.) Your first theory as to why IC...

Jan 31, 2013
Post comments count 0
Post likes count 1

The somewhat misguided question of whether MapViewOfFile or WriteProcessMemory is faster

Raymond Chen

A customer asked, "Which is faster for copying data from one process to another; or ?" This is one of those "Huh?"-type questions, where the customer has solved half of a problem and is looking for help with the other half, the half that makes no sense. First of all, the question is malformed because does not copy any data at all. It takes existing data and maps it into a process. No copy takes place; both processes are seeing the same memory block, and if the memory is modified via one mapping, the change will be visible in other mappings. It's like asking "Which company has better wireless telephone ...

Jan 30, 2013
Post comments count 0
Post likes count 1

Why doesn’t HeapValidate detect corruption in the managed heap?

Raymond Chen

A customer had a program that was corrupting the managed heap by p/invoking incorrectly. The problem didn't show up until the next garbage collection pass, at which point the CLR got all freaked-out-like. "According to Knowledge Base article 286470, the tool is supposed to catch heap corruption, but it doesn't catch squat." Depending on your point of view, this is either a case of the customer not understanding what things mean in context or of the KB article author looking at the world through kernel-colored glasses. The tool, pageheap, full pageheap, and the function all operate on heaps, but the sen...