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

What happens if you pass a source length greater than the actual string length?

Many functions accept a source string that consists of both a pointer and a length. And if you pass a length that is greater than the length of the string, the result depends on the function itself. Some of those functions, when given a string and a length, will stop either when the length is exhausted or a null terminator is reached whichever comes first. For example, if you pass a greater than the length of the string to the function, it will stop at the null terminator. On the other hand, many other functions (particularly those in the NLS family) will cheerfully operate past a null character if you ask...

Japanese street fashion reaches Finland

På hemsidan av Martin Frid, en av programledarna av NHK:s japanska nyheter på svenska, hittade jag dem här fotona av japanskt gataklädemode... i Finland! (Don't worry, the web site is in English.) Nu behöver du inte resa till Japan. Om det är en positiv utveckling är jag inte helt säker på...

Why is my delay-rendered format being rendered too soon?

Here's a customer question: I've put data on the clipboard as delay-rendered, but I'm getting a request for my for many operations even though nobody actually looks at the files. Operations such as right-clicking a blank space on the desktop or opening the Edit menu. I don't want to render the data until the user hits Paste because generating the data requires me to download the file from a Web server. The format is a list of file names, and at the time the format is generated, the files must already exist. That's because the whole purpose of is to describe files that already exist. These simple operations...

Nearly everybody has a $500 flashlight

When I described using a laptop computer as an impromptu flashlight, that triggered a lot of comments from people using their cell phone or PDA as a flashlight. One nickname I've heard for this phenomenon is "the $500 flashlight", $500 being the price of a PDA or SmartPhone at the time the term was coined. (I was amused to find that even Scott Adams does this.) A few years ago, on a trip to Tikal, I took part in a pre-dawn hike into the park in order to observe the sunrise from atop Temple IV. For many people (including me), this was an impulse tour rather than a planned option, so we hadn't packed flashlig...

What do I do with per-user data when I uninstall?

If the user chooses to uninstall your program, what do you do with the data your program kept in , and other parts of the user profile? Should you enumerate all the profiles on the machine and clean them up? No. Let the data go. First, messing with the profiles of users that aren't logged on can result in data corruption, as we saw when we looked at roaming user profiles. Users don't like it when their data get corrupted. Second, the users might want to keep that local data, especially if they are uninstalling your program only temporarily. For example, maybe your program's installation got corrupted and the...

Another type of misplaced apology: Apologizing for not knowing the penalty

You may remember this story from a few years ago. A college student printed his own bar codes (for inexpensive items), placed them over the bar code for expensive items, then went through the register and ended up paying $4.99 for a $149.99 iPod, for example. Ironically, he would have gotten off lighter if he had merely shoplifted the items, because manufacturing fake bar codes brings the crime to the level of forgery, a felony. But what really struck me was the nature of the apology. He didn't say, "I should not have done it," or even the unconvincing "I didn't know it was wrong" He said, "I did this not kn...

The code page on the server is not necessarily the code page on the client

It's not enough to choose a code page. You have to choose the right code page. We have a system that reformats and reinstalls a network client computer each time it boots up. The client connects to the server to obtain a loader program, and the loader program then connects to the server to download the actual operating system. If anything goes wrong, the server sends an error message to the client, which is displayed on the screen while it's still in character mode. (No Unicode available here.) Initially, we used to generate the error message, but somebody told us we should use followed by . I'm not sure wh...

Snatching defeat from the jaws of victory now more popular than vice versa

If you go to your favorite search engine and search for the phrase "defeat from the jaws of victory", you'll find that it turns up several times more its than the phrase "victory from the jaws of defeat". I just find it oddly amusing that the joke has become more popular than the phrase it came from.

Why isn't QuickEdit on by default in console windows?

In the properties of console windows, you can turn on QuickEdit mode, which allows the mouse to be used to select text without having to go explicitly into Mark mode. (In a sense, the console window is permanently in Mark mode.) Why isn't this on by default? It's so useful! Somebody thought the same thing and changed the default in one of the earlier versions of Windows (my dim recollection was that it was Windows 2000) without telling anyone, especially not the manager responsible for the feature itself. The change was slipped in late in the game and made it into the released product. And then all the co...