The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

Why seventh grade students want to go to weddings
Jul 25, 2008
Post comments count 0
Post likes count 0

Why seventh grade students want to go to weddings

Raymond Chen
Raymond Chen

My friend the seventh-grade teacher is getting married this summer, and when her students learned about the impending nuptials, they couldn't contain their excitement. The students asked her if there was going to be a chocolate fountain. Because you can't not have a chocolate fountain. When they learned that, no, there will not be a chocolate fountain, the students lobbied hard for her to reconsider and please, you have to have a chocolate fountain. The concept of a fancy party without a chocolate fountain defied comprehension. I mean, isn't a chocolate fountain the definition of a fancy party? Naturally, ...

Simulating a drop, part two
Jul 25, 2008
Post comments count 0
Post likes count 0

Simulating a drop, part two

Raymond Chen
Raymond Chen

Last time, we wrote a tiny program to simulate dropping a file on another file, but we discovered that it didn't work for dropping a file onto Mail Recipient.MAPIMail. The reason, as you no doubt instantly recognized, is that the MAPIMail handler creates a worker thread, and we're exiting the process before the worker thread has finished its work. And as you no doubt know by now, the solution is to use the SHSetInstanceExplorer function. Let's bring back the ProcessReference class and use it to solve our process lifetime problem. int __cdecl wmain(int argc, WCHAR **argv) { ProcessReference ref; ... Comp...

Reading a contract from the other side: Simulating a drop
Jul 24, 2008
Post comments count 0
Post likes count 0

Reading a contract from the other side: Simulating a drop

Raymond Chen
Raymond Chen

Most people, when they think of the IDropTarget interface, think only of implementing a drop target. But you can read the contract from the other side, because the description of how a drag source interacts with a drop target tells you how to be a drag source. To summarize, the sequence of drop target operations go like this: IDropTarget::DragEnter is called to indicate that an object has been dragged into the drop target. If the drop target returns a failure code, then the drop operation ends immediately. Otherwise, IDropTarget::DragOver calls are made to advise the drop target as to the obj...

Things other people have written that have amused me
Jul 23, 2008
Post comments count 0
Post likes count 0

Things other people have written that have amused me

Raymond Chen
Raymond Chen

I occasionally post things I've written that have amused other people, but today I'm going to share something Betsy Aoki wrote that amused me. On one of our internal mailing lists, somebody wondered why we don't use email spam filters to attack comment spam and trackback spam. My point was that the goal of email spam is very different from the goals of comment spam and trackback spam: I concluded with the remark, "I am not aware of any email spam that takes messages that I wrote and forwards them back to me." Betsy replied, "I encounter this all the time. It's called working at Microsoft."

Theorize if you want, but if the problem is right there in front of you, why not go for the facts?
Jul 23, 2008
Post comments count 0
Post likes count 0

Theorize if you want, but if the problem is right there in front of you, why not go for the facts?

Raymond Chen
Raymond Chen

On an internal discussion list, somebody asked a question similar to this: My program launches a helper program. This helper program does different things based on the command line parameters, but the way I'm using it, it just prints its results to the console and exits. When I launch this program and wait for it to exit, my wait never completes. Why isn't the helper program exiting? Here's the code that I'm using to launch the helper process... It wasn't long before people chimed in with their suggestions. Have your main program call exit() at the end. If you're redirecting stdout, you may be forgetti...

The Microsoft Company Picnic has as a side effect a demonstration of Microsoft’s rich cultural diversity
Jul 22, 2008
Post comments count 0
Post likes count 0

The Microsoft Company Picnic has as a side effect a demonstration of Microsoft’s rich cultural diversity

Raymond Chen
Raymond Chen

You hear parents scolding their kids in so many different languages.

Windows could not properly load the XYZ keyboard layout
Jul 22, 2008
Post comments count 0
Post likes count 0

Windows could not properly load the XYZ keyboard layout

Raymond Chen
Raymond Chen

In my rôle as the family technical support department, I get to poke around without really knowing what I'm doing and hope to stumble across a solution. Sometimes I succeed; sometimes I fail. Today, I'm documenting one of my successes in the hope that it might come in handy for you, the technical support department for your family. (If not, then I guess today is not your day.) The boot drive on the laptop belonging to one of my relatives became corrupted, and her brother-in-law had the honor of extracting the drive, sticking it into a working computer, doing the magic, reinstalling the software that ...

A modest proposal: Getting people to stop buying SUVs
Jul 21, 2008
Post comments count 0
Post likes count 0

A modest proposal: Getting people to stop buying SUVs

Raymond Chen
Raymond Chen

I developed this modest proposal many years ago, but it looks like rising gasoline prices have done the job. But in case they don't, here's my plan. SUVs are classified as "trucks" for the purpose of C.A.F.E. regulations, and those regulations are more lenient on gasoline efficiency for trucks. As a result, the auto industry happily built SUVs safe in the knowledge that high SUV sales wouldn't lower their overall fleet mileage and therefore not risk violating the CAFE regulations. On the other hand, most other highway regulations do not consider SUVs to be trucks. As a result, SUVs sit in this sweet spot ...

MessageBoxIndirect loads the icon itself; you can’t hand it a pre-loaded icon
Jul 21, 2008
Post comments count 0
Post likes count 0

MessageBoxIndirect loads the icon itself; you can’t hand it a pre-loaded icon

Raymond Chen
Raymond Chen

Commenter 8 wants to know how to tell the function to use an existing instead of pointing it to an icon resource. You can't. The loads the icon itself. You can't hand it a pre-loaded icon. Of course, it's hardly rocket science to write your own function that lets you use whatever icon you want. There's no law that says all Yes/No dialogs must use the function. Feel free to write your own. The and functions are just convenience functions. They don't create new functionality; they don't do anything you couldn't already do yourself. You can have a template dialog box that you use for "generic" pur...