The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

Jan 18, 2012
Post comments count 0
Post likes count 1

Don't try to allocate memory until there is only x% free

Raymond Chen

I have an ongoing conflict with my in-laws. Their concept of the correct amount of food to have in the refrigerator is "more than will comfortably fit." Whenever they come to visit (which is quite often), they make sure to bring enough food so that my refrigerator bursts at the seams, with vegetables and eggs and other foodstuffs crammed into every available nook and cranny. If I'm lucky, the amount of food manages to get down to "only slightly overfull" before their next visit. And the problem isn't restricted to the refrigerator. I once cleared out some space in the garage, only to find that they decided to use...

Jan 17, 2012
Post comments count 0
Post likes count 1

Microspeak: Walls and ladders

Raymond Chen

Reader laonianren wanted to know more about this game Walls and Ladders. "Walls and Ladders" is not a game. It's just a metaphor for a conflict in which one side wants to perform some action and the other side wants to prevent it. The defending side builds a wall, and the attacking side builds a taller ladder. In response, the defending side builds a taller wall, and the attacking side builds an even taller ladder. The result of this conflict is that the defending side constructs an ever-more-elaborate wall and the attacking side constructs a more-and-more complex ladder [link possible NSFW], both sides expen...

Jan 16, 2012
Post comments count 0
Post likes count 1

Cultural arbitrage: The food-related sucker bet

Raymond Chen

While I was at a group dinner at a Chinese restaurant, a whole fish was brought to our table. One of the other people at the table told a story of another time a whole fish was brought to the table. He attended the wedding rehearsal dinner of a family member. The bride is Chinese, but the groom is not. (Or maybe it was the other way around. Doesn't matter to the story.) The dinner was banquet-style at a Chinese restaurant, and one of the many courses was a whole fish. Two of the non-Chinese attendees marveled at the presence of an entire fish right there in front of them, head, tail, fins, and all. I guess they...

Jan 16, 2012
Post comments count 0
Post likes count 2

Why was there a font just for drawing symbols on buttons?

Raymond Chen

Nice and scalable.

Jan 13, 2012
Post comments count 0
Post likes count 1

Keys duplicated from photo: Delayed reaction

Raymond Chen

There was a report some time ago that researchers have developed a way to duplicate keys given only a photograph. When I read this story, I was reminded of an incident that occurred to a colleague of mine. He accidentally locked his keys in his car and called a locksmith. Frustratingly, the keys were sitting right there on the driver's seat. The locksmith arrived and assessed the situation. "Well, since you already paid for me to come all the way out here, how would you like a spare key?" "Huh? What do you mean?" The locksmith looked at the key on the driver's seat, studied it intently for a few seconds, then...

Jan 13, 2012
Post comments count 0
Post likes count 1

How do I print non-error messages during compilation?

Raymond Chen

Commenter Worf remarked, "My one wish is that would be supported." I always find it interesting when people say "I wish that Microsoft would stop following standards," since the directive is nonstandard. The Microsoft C/C++ compiler implements the feature in a method compatible with the standard, namely via a directive. If you want to warn people away from deprecated functionality, you can use the directive or the even more convenient (but more standards-troublesome) declaration specifier. The declaration specifier is much more convenient than the preprocessor directive because you can...

Jan 12, 2012
Post comments count 0
Post likes count 1

Puzzling out the upsell-o-meter

Raymond Chen

As I noted before, many grocery stores in the United States have a printer next to the cash register which prints out coupons customized to your purchases. Here's a purchase and the accompanying coupon. What is the story behind this pairing? Purchased: Diapers for newborn baby. Coupon: Save 75 cents on ice cream. Bonus chatter: While waiting in line, I read the warning label on the diapers. It went on for quite a bit, but one part triggered my "I wonder what lawsuit led to this warning" sensor: "Like most articles of clothing, XYZ brand diapers will burn if exposed to flame." Did somebody say, "Oh no, there's ...

Jan 12, 2012
Post comments count 0
Post likes count 1

Why does CreateEvent fail with ERROR_PATH_NOT_FOUND if I give it a name with a backslash?

Raymond Chen

A customer reported that the function was failing with the unusual error code : The customer continued, "The documentation for says that the parameter must not contain the backslash character. Clearly we are in error for having passed an illegal character, but why are we getting the strange error code? There is no file path involved. Right now, we've added to our list of possible error codes, but we'd like an explanation of what the error means." Okay, first of all, building a table of all known error codes is another compatibility problem waiting to happen. Suppose in the next version of Windows, a new...

Jan 11, 2012
Post comments count 0
Post likes count 1

What a steal: A house for only ten dollars!

Raymond Chen

When I was signing the papers for a house purchase many years ago, I noticed that the deed papers read The Grantor «names of people selling the house» for and in consideration of TEN DOLLARS AND OTHER GOOD AND VALUABLE CONSIDERATION in hand paid, conveys and warrants to «me» the following described real estate... I noticed that I technically was buying the house for ten dollars. The closing agent explained, "Well, ten dollars and other consideration. This is just a convention, so that the actual amount paid for the house doesn't go into the record." It also saves them from havin...