The Old New Thing
Practical development throughout the evolution of Windows.
Latest posts

Arrived in Urbana-Champaign for Reflections|Projections 2009

Today was a long travel day. I left my office at 9:30am to catch the bus from Redmond to downtown Seattle, then took the train to the Tukwila station, then took the shuttle bus to Seattle-Tacoma International Airport (because Airport Station doesn't open until later this year), then flew to Chicago O'Hare airport, and then drove to Urbana-Champaign, with a stop at the Bourbonnais Steak and Shake on the recommendation of a friend as a good stopping point—about halfway—and an introduction to classic Midwest road food, arriving (after several wrong turns) at my hotel at midnight. If only there were a ...

Important window message numbers to memorize

You probably know them already, but if you're new to Win32, here are some key window messages. I would normally suggest that you commit them to memory, but if you do enough debugging, you'll end up memorizing them anyway because you see them all the time. I include in the list even though it is a low-traffic message because you do see it a lot when you are investigating hangs. The (which also goes by the name ) is a common culprit when investigating why your program has wedged: You're broadcasting a notification and there's a window in the system that isn't responding. I know that Visual Studio has a shortc...

Don't use global state to manage a local problem, practical exam

There was much speculation as to how the "Ignore other applications that use Dynamic Data Exchange" setting got set. Well, one possibility is that somebody used global state to manage a local problem. "Why on earth does this setting exist?" I don't know, but there appear to be scripts which rely on it. The setting is exposed to scripts, and perhaps at some point you ran a script which didn't want Excel to be interrupted while it was running. The documentation for the Excel Application Object does say that it contains application-wide (global) settings. I'm not saying that's why you are encountering the pr...

Viral video: Pianotrappan

Yes, it's an advertisement for Volkswagen, but still, it's a fun video, and it features Scarlatti's keyboard sonata in C (K159) as a bonus. Even the old guy who shuffles along slowly at 1:23 tries the stairs. Double bonus: You can watch the original Swedish version.

When you want to pass a parameter on the command line, don't forget to pass the parameter on the command line

This happens to me, too. I once got so distracted by the process of purchasing some tickets in person, choosing the performance date and the seats, fumbling for my credit card, signing the receipt, and when I was done, I left the ticket booth without my tickets! Here is a question that came in from a customer. The details have been changed but the underlying point is the same. According to the documentation, the command prints a history log of all the tags in the system. I can pass the option to limit the date range, and that works too. It also says that that I can pass a specific tag name to limit the li...

You always hurt the things you love

I've tried all sorts of miniature headphones, and the only ones that I like are the ones that come with my Zune. What makes them special? They fit and don't fall out. I try not to be too demanding. But the other day, I was getting out of my car, and due to a badly-stowed Zune, the headphones dangled out of my pocket and got caught in the door. Before I realized what happened, I had taken a few steps away from the car, and the headphones snapped. You always hurt the things you love, because if you didn't love them, you wouldn't use them all the time and accidentally break them. (Well, and when you hurt the thi...

Why do we have import libraries anyway?

Last time we looked at the classical model for linking as groundwork for answering Adam's question why do we need import libraries? Why can't all the type information be encoded in the export table? At the time the model for DLLs was being developed, the classical model still was the primary means by which linking was performed. Men were men and women were women. Compilers generated object modules, and linkers resolved symbols, connecting the loose ends of the object modules, in order to produce an executable. The linker didn't care what language the object modules were written in; in fact it had no way of fin...

The classical model for linking

Commenter Adam wonders why we need import libraries anyway. Why can't all the type information be encoded in the export table? This goes back to the classical model for linking. This model existed for decades before Microsoft was even founded, so at least this time you don't have Bill Gates to kick around. (Though I'm sure you'll find a way anyway.) Back in the days when computer programs fit into a single source file, there was only one step in producing an executable file: You compile it. The compiler takes the source code, parses it according to the rules of the applicable language, generates machine cod...

LoadString can load strings with embedded nulls, but your wrapper function might not

Whenever somebody reports that the function or the member of the structure is not working, my psychic powers tell me that they failed to manage the double-null-terminated strings. Since string resources take the form of a counted string, they can contain embedded null characters, since the null character is not being used as the string terminator. The function knows about this, but other functions might not. Here's one example: The problem is that you're using a function which operates on null-terminated strings but you're giving it a double-null-terminated string. Of course, it will stop copying at...