The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

Dec 4, 2013
Post comments count 0
Post likes count 1

What's the difference between the wParam of the WM_NOTIFY message and the idFrom in the NMHDR structure?

Raymond Chen

The message takes the following parameters: Notice that the identifier of the control sending the message appears in two places, once in the and again in the . What's the difference? There is no difference. It's just a convenience. The same value is passed in both places, and you can check whichever one is easier for you. You might use the because it avoids having to dereference a pointer. You might use the because that way you have only one thing to pass to your helper function. Whatever floats your boat. Passing the same information multiple ways is hardly new. The message also passes redundant inf...

Dec 3, 2013
Post comments count 0
Post likes count 1

Sir, is this your high-speed ferry?

Raymond Chen

The Victoria Clipper is a high-speed ferry that runs primarily between Seattle and Vancouver Victoria, BC. Early Sunday morning, a man scaled a fence and drove off with one of the boats. The issue was resolved without major incident and only minimal damage, which means that it is now open season on jokes! "Why yes, officer, this is my ferry. I must have left the registration in my other pants." According to the vessel superindendent, "There is a joystick and he thought it was like an Xbox," ending up driving the boat in circles. You can see the GPS track here (photo 19). Of course, if the thief had had a K...

Dec 3, 2013
Post comments count 0
Post likes count 1

How do I configure the timeout used by UI0Detect (Interactive Services Detection service)?

Raymond Chen

Windows Vista introduced Session 0 Isolation which enforces the rule that services should not display UI. If a service tries to display UI, another service known as the Interactive Services Detection service detects this situation and signals the user that a service wants to display UI and gives the user an opportunity to switch to the service desktop, respond to the UI, and then switch back. If the user ignores the service for about one minute, it switches back automatically, on the assumption that something went bad with the detection and the service is actually finished with its UI. (That way, the user ...

Dec 2, 2013
Post comments count 0
Post likes count 1

The walls of my friend's house sometimes randomly got corrupted

Raymond Chen

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...

Dec 2, 2013
Post comments count 0
Post likes count 1

Logging the foreground process as it changes

Raymond Chen

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...

Nov 29, 2013
Post comments count 0
Post likes count 1

Notes on gift card and gift certificates in the state of Washington

Raymond Chen

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". ...

Nov 29, 2013
Post comments count 0
Post likes count 1

Why can't I create my dialog with DialogBox, DialogBoxParam, CreateDialog, CreateDialogParam, or the indirect versions of same?

Raymond Chen

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...

Nov 28, 2013
Post comments count 0
Post likes count 0

Things that can happen when your kitchen gets taken over by others

Raymond Chen

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. ...

Nov 28, 2013
Post comments count 0
Post likes count 1

If you try to declare a variadic function with an incompatible calling convention, the compiler secretly converts it to cdecl

Raymond Chen

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...