The Old New Thing
Practical development throughout the evolution of Windows.
Latest posts

Psychic debugging: Why does ExitProcess(1) produce an exit code of zero?

Here's a question that came from a customer. By now, you should already have the necessary psychic powers to answer it. Our program calls to indicate that it exited unsuccessfully. The process that launched our program waits for the program to exit and then calls to retrieve the exit code. The function succeeds, but the exit code is zero! How can this be? Hint: Read about how processes terminate on Windows XP.

News flash: It's dangerous to drive a car if you are blind

The BBC reminds us that if you have no eyes, it's dangerous for you to drive a car. Follow-up: The man was given a suspended jail sentence and—I am not making this up—has been banned from driving for three years. Three years?

If you pass invalid parameters, then all bets are off

Alun Williams pointed out that if you pass invalid parameters to , it does not destroy the . Well, yeah, because if you pass invalid parameters, then all bets are off. Different functions perform different degrees of parameter validation; the degree to which this is done is typically guided by security concerns. Information that crosses security boundaries must be fully-validated, whereas a call to an in-process function has very little in the way of security obligations with respect to invalid parameters, since a bad caller could just mess with the in-process function directly; no need to try to "trick" it ...

Canoeing around the Washington Park Arboretum

This weekend is Opening Day of the Seattle boating season. Even if you don't own a boat, you can enjoy the warmer weather and rent a canoe and paddle around the Arboretum. (Don't do it on Opening Day, though.) Here's a nice map courtesy of the Northwest Outdoor Center. Pay heed to avoid the green section marked Caution. I made a wrong turn and ended up in the Caution area, and I found myself slogging through very shallow water. Assuming you avoid the shallows, it's a very pleasant experience. Commune with the ducks and other birds. Pull over at one of the beaches and take a lunch break (assuming you rememb...

You didn't know you could add properties by atom, and it's a good thing you didn't know

As I noted a few days ago, there is weirdness associated with properties added by atom. This weirdness stems from the fact that adding properties by atom is really a hole in the original implementation rather than something designed on purpose. The original 16-bit code for adding and removing properties went roughly like this: First, let's look at properties set and removed via integer atoms. These are simple: When setting the property, we just add it to the property list, and when removing the property, we remove it. Nothing fancy going on here. Similarly, there's nothing particularly exciting going on ...

Why every advertising agency needs to have a review panel of twelve-year-old boys

To spot the gaffe before your customers do.

Strange uses for window class atoms

When you register a window class (with the or function), you get an back. What use is this atom? Not much. You can use this atom in many places where a window class name can be used; just convert it to a string with the macro. Let's change our scratch program to illustrate: We save the atom returned by the function and use it (in the form of a ) in place of the class name. if you run this program, you'll see that it works exactly the same as the old version that used the class name. The class atom is valid as long as the class remains registered. Functions that accept a as the class name include...

Book me the next flight to Tokyo, no wait, the second flight

I know someone who has a brother who works in Taipei, Taiwan. He travels to Japan often on business, and one day he needed to fly to Tokyo on short notice. He instructed his assistant to book the next flight from Taipei to Tokyo. This is what he got. (Warning: Contains strange music.) That's right. His assistant booked him on Hello Kitty Air, initially a daily flight from Taipei to Fukuoka, but soon extended to a second run to Tokyo. Everything on this plane is Hello Kitty. The paint scheme, the flight attendants, the boarding passes, the luggage tags, the chopsticks, the sugar packets, the in-flight meals, ...

Some other places atoms (and the magical 0xC000) arise

The moment the Windows developers got a system for converting strings into numbers, they could use it anywhere they need to, well, convert a string into a number. Somtimes these integers are officially declared as atoms, but most of the time they are just integers that happen to be atoms under the covers. I'll start with registered window messages, created by the function. These are not officially atoms; they are just integers that happen to lie in the range to , just like atoms. But yeah, internally, they're atoms. Of course, you shouldn't rely on it since it's not contractual. Think of it as a fantastic coin...