The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

Nov 30, 2009
Post comments count 0
Post likes count 0

Umpires are the lymphatic system of the baseball diamond

Raymond Chen

When I go to a baseball game, I try to remember to watch the umpires. They move around in a counter-intuitive way: They don't run toward the ball. They don't run toward the runner. Even when the ball is far away, the umpire runs from what appears to be one irrelevant position on the field to another equally irrelevant position. Yet no matter what eventually happens, there's always an umpire there to make the necessary call. (As opposed to the players on the field, who sometimes forget to cover third base.) That's because the umpires aren't playing the game of baseball as it happens on the field. They're playing...

Nov 30, 2009
Post comments count 0
Post likes count 3

Where did WIN32_LEAN_AND_MEAN come from?

Raymond Chen

Commenter asdf wonders where came from. The symbol was introduced in the Windows 95 time frame as a way to exclude a bunch of Windows header files when you include . You can take a look at your file to see which ones they are. The symbol was added as part of the transition from 16-bit Windows to 32-bit Windows. The 16-bit header file didn't include all of those header files, and defining brought you back to the 16-bit Windows philosophy of a minimal set of header files for writing a bare-bones Windows program. This appeased the programmers who liked to micro-manage their header files, and it was a bi...

Nov 27, 2009
Post comments count 0
Post likes count 0

How does Raymond get rid of his excess pennies?

Raymond Chen

Commenter Boris mentions that he uses NJ Transit to get rid of his excess pennies. But what do you do if your area isn't served by NJ Transit? I use the self-checkout line at the grocery store. The machine has a slot for accepting coins, and you can drop pennies in there until your arm falls off. I don't do this when the grocery store is crowded, since this holds up the line. (Yes, banks also have change-counting machines, but using the machine is overkill when you have only thirty pennies to get rid of.)

Nov 27, 2009
Post comments count 0
Post likes count 1

Caches are nice, but they confuse memory leak detection tools

Raymond Chen

Knowledge Base article 139071 has the technically correct but easily misinterpreted title FIX: OLE Automation BSTR caching will cause memory leak sources in Windows 2000. The title is misleading because it makes you think that Oh, this is a fix for a memory leak in OLE Automation, but that's not what it is. The is the string type used by OLE Automation, and since strings are used a lot, OLE Automation maintains a cache of recently-freed strings which it can re-use when somebody allocates a new one. Caches are nice (though you need to make sure you have a good replacement policy), but they confuse memory leak ...

Nov 26, 2009
Post comments count 0
Post likes count 0

I want to take all your chocolate milk

Raymond Chen

My older niece visited me at work one day, and I got her a carton of chocolate milk, which she very much enjoyed. Some days later, she told me, "I want to go to your work." "Why?" I asked. "I want to take all your chocolate milk." Missing from the story is that upon returning home after that first visit, she told everybody about her awesome visit with her uncle, and that he even got her a chocolate milk from the refrigerator. "And the chocolate milk is free, you can just take it!" Her uncle (not me, a different uncle) told her, "Then you should go there with a knapsack and take all the chocolate milk." That ...

Nov 26, 2009
Post comments count 0
Post likes count 1

When you want to copy a file into a folder, make sure you have a folder

Raymond Chen

This story is inspired by an actual customer problem. The program is used for TPS management, and when you want to create a new TPS report, you have to pick a cover sheet. The program shows you the cover sheets that have been defined, which it loads from the directory. The customer found that on one of the machines, the cover sheets weren't showing up, even though the standard system setup copies a sample cover sheet into the directory. The error message they got was Cannot load cover sheets. The directory name is invalid. The customer did some troubleshooting and determined that "The cover sheet direc...

Nov 25, 2009
Post comments count 0
Post likes count 0

The magic of chocolate milk

Raymond Chen

While enjoying a meal with my nieces (at the time, ages 3 and 5), I diluted my chocolate milk to cut the sweetness. The nieces then demanded that I dilute their chocolate milk as well, because as far as they could determine, it was a magical way to create more chocolate milk.

Nov 25, 2009
Post comments count 0
Post likes count 1

How do I get the command line of another process?

Raymond Chen

Win32 doesn't expose a process's command line to other processes. From Win32's point of view, the command line is just a conveniently initialized parameter to the process's startup code, some data copied from the launching process to the new process and forgotten. We'll get back to the Win32 point of view a little later. If you look around in WMI, you'll find a object, and lo and behold, it has a property. Let's check it out, using the standard WMI application: I fully anticipate that half of my readers will stop right there. "Thanks for the script. Bye!" And they won't bother reading the analysis. "Bec...

Nov 24, 2009
Post comments count 0
Post likes count 0

When computer programmers dabble in making change

Raymond Chen

My colleague who dabbled in economics when deciding how many lunch vouchers to buy had a number of other money-related quirks. One of the ones that I remember is that when paying for a purchase, my colleague would double the balance and give the cashier that much money. For example, if the total was $5.20, my colleague would hand over $10.40. Why? Just to see if the cashier reacted when pressing the Enter code appeared to have no effect. Total is $5.20. Cash tendered is $10.40. Change is $5.20. Most of the time, the cashier wouldn't pay any attention. Heck, the cashier wouldn't even question why my collea...