The Old New Thing
Practical development throughout the evolution of Windows.
Latest posts
The walls of my friend's house sometimes randomly got corrupted
One evening, I had a series of three dreams. In each one, I visited an unusual home. In the third dream, I visited the home of a friend of mine. He lived in a white stucco split-level, a stereotypical suburban home. What made the house interesting was that if you did things just right, dark dots would appear on the wall and slowly consume it. My friend explained, "This house is running a very old build of DirectX, and sometimes it just does that." We set up a repro and calculated that when the dots appeared, stack usage was exactly 5124 bytes. This was a 16-bit house, and the stack overflow into the heap cause...
Logging the foreground process as it changes
Today's Little Program simply logs all changes to the foreground window by recording the path to the application the user switched to. You might use this as part of a usability study to monitor what applications users spend most of their time in. Most of this code is just taking things we already know and snapping them together. Using accessibility to monitor events, specifically to monitor foreground changes. to get the process ID from a window. to get a handle to a process given the process ID. to get the path to the application from the handle. (For Windows XP, yo...
Notes on gift card and gift certificates in the state of Washington
Today is the unofficial start of the holiday shopping season. One of my colleagues read the fine print of a gift card he received: A monthly maintenance fee of $3 applies but is waived for the first twelve months after the card is issued. Thereafter, monthly maintenance fees are waived for an additional three months if the card is used in any given month. This seems kind of backwards. They charge a maintenance fee if you don't create any work for them. Shouldn't the maintenance fee be charged when you use the card, rather than when you don't? This "maintenance fee" is really just an "account inactivity fee". ...
Why can't I create my dialog with DialogBox, DialogBoxParam, CreateDialog, CreateDialogParam, or the indirect versions of same?
One of the purposes of my dialog manager series was to help people diagnose problems with their dialog boxes. But since I embedded the tips inside the series body, it's hard for people to find them, and I still end up answering the same questions over and over. So here it is in a separate article that hopefully people can find. Why your call to or is failing. This also goes for , but perhaps extra so because the MFC source code says even though the problem is rarely due to an error in the template. A wrong comment is worse than no comment at all.¹ I've decided to put the reasons in most-likely-e...
Things that can happen when your kitchen gets taken over by others
Today is the Thanksgiving holiday in the United States, one of the the major holidays for family get-togethers. (Another big one is Christmas.) One year, it was our family's turn to host Thanksgiving, and when that happens, it means that the kitchen is overrun by relatives cooking all the dishes and hunting through the cabinets and drawers of an unfamiliar kitchen. One year, I learned that a pastry blender can be used as a potato masher and that a cheese planer can be used as a pie server. This is what happens when other people use your kitchen. It could also mean that my kitchen has too many froofy gadgets. ...
If you try to declare a variadic function with an incompatible calling convention, the compiler secretly converts it to cdecl
Consider the following function on an x86 system: The function declares itself as , which is a callee-clean convention. But a variadic function cannot be callee-clean since the callee does not know how many parameters were passed, so it doesn't know how many it should clean. The Microsoft Visual Studio C/C++ compiler resolves this conflict by silently converting the calling convention to , which is the only supported variadic calling convention for functions that do not take a hidden parameter. Why does this conversion take place silently rather than generating a warning or error? My guess is that it's...
The case of the DLL that refuses to load
A customer reported that they had a problem that occurred only on some machines but not others. Their application called and the call succeeded on some machines, but failed on others with error ("The specified module could not be found"). The path was a fully-qualified path to a file that was confirmed to exist and be readable. If the command was used in the debugger to break when the DLL loads, the breakpoint does fire, but a breakpoint on Contoso's is never hit. "I think this means that the problem is not that Contoso failed to initialize, but what does it mean?" If you get a break from but no brea...
Why did Raymond bring a knitting bag to every meeting?
I stopped knitting a few years ago, but back when I knitted regularly, I tended to bring my knitting bag with me everywhere I went. There are a lot of idle minutes in your typical day. Waiting for the bus, waiting in line for the ATM, waiting for a meeting to start. There's not enough time in those idle minutes to do anything substantial, but it's enough time to sneak in a little bit of knitting. But there's another reason I brought a knitting bag to every meeting. Nothing says "I don't care about this meeting" like knitting.
My friend lived in an apartment inside a museum
One evening, I had a series of three dreams. In each one, I visited an unusual home. In the second dream, I visited the home of a friend of mine. She lived in a modern luxury apartment inside an art museum. It was a little tricky, because you could visit her only during museum hours. If you stayed past closing time, then you were locked inside the museum, and you were spending the night whether you liked it or not. On the other hand, it meant that you could go out an view the art to your heart's content without any crowds. And no, the museum did not come to life. You just got free run of a museum for the nigh...