The Old New Thing
Practical development throughout the evolution of Windows.
Latest posts
Microspeak: The bug farm
In its most general sense, the term bug farm refers to something that is a rich source of bugs. It is typically applied to code which is nearly unmaintainable. Code can arrive in this state through a variety of means. The term is most often used as a cautionary term, calling attention to areas where there is high risk that code you're about to write is going to result in a bug farm. Aren't we setting ourselves up for a bug farm? This could easily lead to a bug farm from different lifetimes for this various state objects. The term is quite popular at Microsoft (pre-emptive snarky comment: because Microsoft ...
The clipboard viewer linked list is no longer the responsibility of applications to maintain, unless they want to
Commenter Nice Clipboard Manager (with drop->clipboard) wonders why Windows still uses a linked list to inform programs about clipboard modifications. If any clipboard viewer fails to maintain the chain, then some windows won't get informed of the change, and if a clipboard viewer creates a loop in the chain, an infinite loop results. Well, sure, that's what happens if you use the old clipboard viewer chain. So don't use it. The old clipboard viewer chain remains for backward compatibility, but it's hardly the best way to monitor the clipboard. (This is another example of people asking for a feature that ...
Why can't I PostMessage the WM_COPYDATA message, but I can SendMessageTimeout it with a tiny timeout?
After receiving the explanation of what happens to a sent message when reaches its timeout, a customer found that the explanation raised another question: If the window manager waits until the receiving thread finishes processing the message, then why can't you post a message? "After all, with a very short timeout isn't all that different from ." Actually, with a very short timeout is completely different from . Let's set aside the one crucial difference that, unlike messages posted by , which cannot be recalled, the function will cancel the message entirely if the receiving thread does not process messa...
Some preliminary notes from //build/ 2011
Hey everybody, I'm down at the //build/ conference. (The extra slash is to keep the d from falling over.) I'm not speaking this year, but you can find me in the Apps area of the Expo room today until 3:30pm (except lunchtime), and Friday morning before lunch. I'll also be at Ask the Experts tonight. There are so many great sessions to choose from. The one I would attend if I weren't working that time slot would be Bring apps to life with Metro style animations in HTML5. Instead, I'll probably go to Building high performance Metro style apps using HTML5. Fortunately, the sessions are being recorded, so I can ca...
What happens to a sent message when SendMessageTimeout reaches its timeout?
The function tries to send a message, but gives up if the timeout elapses. What exactly happens when the timeout elapses? It depends. The first case is if the receiving thread never received the message at all. (I.e., if during the period the sender is waiting, the receiving thread never called , , or a similar message-retrieval function which dispatches inbound sent messages.) In that case, if the timeout is reached, then the entire operation is canceled; the window manager cleans up everything and makes it look as if the call to never took place. The message is removed from the list of the thread's non-queu...
A common control for associating extensions is well overdue
Mark complained that a common control for associating extensions is well overdue. This is a recurring theme I see in the comments: People complaining that Windows lacks some critical feature that it in fact already has. (In the case, Windows had the feature for over two years at the time the question was asked. Maybe the SDK needs a ribbon? j/k) Windows Vista added the Default Programs UI as a control panel program, and it also has a programmable interface. You can use to query and set default associations, and you can use to invoke the control panel itself on a set of associations associated with yo...
Why are the building numbers on Microsoft main campus so erratic?
Carrie complains that the building numbers on Microsoft main campus are completely random. Why is building 22 near buildings 40 and 41, far, far away from building 24? Because the Microsoft campus evolved. Many many years ago, the space on which the central Microsoft campus resides was a mill. Eventually it became an office park, and when Microsoft decided to move its headquarters there, it carved out a little wooded area and constructed four buildings, logically numbered 1 through 4. Later, the campus expanded, and plans were drawn up for three more buildings, logically numbered (and placed) 5&nbs...
Is this a really bug with CreateWindowEx or am I just confused?
Somebody sent me email pointing out strange behavior in the function if you fail a window creation by returning −1 from the message. On the other hand, returning from seems to work just fine. "So why the difference with ?" You already know enough to solve this puzzle. You just need to connect the dots. (In fact, the person who sent me this topic did so a year after I already answered it. But I'm repeating it here because the original answer was accidentally destroyed.)
Throwing garbage on the sidewalk: The sad history of the rundll32 program
Fix that stack.