The Old New Thing

An auto-reset event is just a stupid semaphore

When you create an event with the function, you get to specify whether you want an auto-reset event or a manual-reset event. Manual-reset events are easy to understand: If the event is clear, then a wait on the event is not satisfied. If the event is set, then a wait on the event succeeds. Doesn't matter how many people are waiting for the ...

Psychic debugging: Understanding DDE initiation

You too can use your psychic powers to debug the following problem: We have a problem with opening documents with our application by double-clicking them in Explorer. What's really strange is that if we connect a debugger to Explorer and set a breakpoint on , then wait a moment after returns, then hit '', then the document opens fine. But...

A single-instance program is its own denial of service

There are many ways a program can establish itself as a single-instance program; I won't go into them here. But once people head down the path of a single-instance program, they bump into another issue in their security review: Denial of service. We are using a named mutex with a fixed name in order to detect whether another copy of the ...

Announcements on the ferry, one self-explanatory, one not

While I was riding the ferry last Saturday, there were two announcements made over the public address system. "All crew please report to the Second Mate's office." What were they all doing in the Second Mate's office? Would the whole crew fit into the office? And while all the crew are in the Second Mate's office, who's steering the ferry? ...

Why can't you programmatically reorder the items on the Start menu?

The classic Start menu and the "All Programs" portion of the Windows XP Start menu permit you to customize the order of the shortcuts that appear there. You can use drag/drop to rearrange them, or force them to be sorted by name. But why is there no programmatic interface to these actions? Because the power would be used for evil far ...

Understanding what significant digits really mean

A double-precision floating point number carries fifteen significant digits. What does this really mean? I multiplied 0.619207 by 10,000,000 and got 6192069.999999991 instead of 6192070. That's only six significant digits; where's my fifteen? Talking about significant digits is really just a shorthand for talking about relative precision. "...

Window class properties apply to all windows that belong to the class

Window class properties apply to all windows that belong to the class. That's why they're called class properties. This seems like an obvious thing to say when put in so many words, but I see many "solutions" that lose sight of this simple fact. All the properties that you set in the (or ) are window class properties, as are the properties...