The Old New Thing

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

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

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

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

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

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

Extracting GPS coordinates from a photo and plotting it on a map

Today's Little Program extracts GPS coordinates from a photo and plots it on a map. Remember, Little Programs do little to no error checking, because that's how they roll. We start with a simple function that takes a latitude and longitude and opens a Web page that highlights that coordinate. In a real program, you probably would do ...

How do I get the path to the default user's profile?

A customer wanted to know how to get the path to the default user's profile. On older versions of Windows, the default location of the default user's profile was . Then it moved to . Now it's in . And the location may have been customized, so in principle it could be anywhere. The function to get the default user profile's directory is is ...

Why is my FormatMessage call crashing trying to read my insertion parameter?

A customer was looking for assistance in debugging a crash in their product. The stack trace looked like this: The string being formatted is , and the insertion is a long (but valid) string. A unit test which passes a similarly long object name to does not crash. What is the problem? There are clues in the stack trace. The natural ...