The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

Enumerating threads in a process
Feb 23, 2006
Post comments count 0
Post likes count 1

Enumerating threads in a process

Raymond Chen
Raymond Chen

The tool helper library is sort of the black sheep of Win32. It grew out of the 16-bit TOOLHELP library, which provided services for system debugging tools to do things like take stack traces and enumerate all the memory in the system. The original incarnation of Win32 didn't incorporate it; it wasn't until Windows 95 that a 32-bit version of the tool helper library sort of got bolted onto the side of Win32. Disowned or not, the functions are still there, so let's give them a spin. Running this program prints a list of all the threads in the system (or at least all the ones you have access to). This i...

Games give you hand-eye coordination and spatial intelligence together with map-reading skills
Feb 22, 2006
Post comments count 0
Post likes count 0

Games give you hand-eye coordination and spatial intelligence together with map-reading skills

Raymond Chen
Raymond Chen

Australian comedy group Tripod performs a song that I'm sure describes none of my readers in any way whatsoever. (Courtesy of my good friend The Knitty Professor.)

The performance cost of reading a registry key
Feb 22, 2006
Post comments count 0
Post likes count 1

The performance cost of reading a registry key

Raymond Chen
Raymond Chen

The registry is a convenient place to record persistent cross-process data in a uniform and multi-thread-safe manner. It roams with the user if you store it in , and individual keys can be secured (even on systems that use FAT, which doesn't otherwise support security). But that doesn't mean that it's free. The cost of opening a key, reading a value, and closing it is around 60,000 to 100,000 cycles (I'm told). And that's assuming the key you're looking for is in the cache. If you open the key and hold it open, then the act of reading a value costs around 15,000 to 20,000 cycles. (These numbers are estimates f...

In pursuit of the message queue
Feb 21, 2006
Post comments count 0
Post likes count 0

In pursuit of the message queue

Raymond Chen
Raymond Chen

In 16-bit Windows, every thread (or "task" as it was called then) had a message queue, end of story. In the transition to 32-bit Windows, this model broke down because Win32 introduced the concepts of "worker threads" and "console applications", neither of which had much need for messaging. Creating a queue for every thread in the system would have been quite a waste, so the window manager deferred creating the input queue for a thread until that thread actually needed an input queue. That way, threads that didn't use the GUI didn't have to pay for something they weren't using. But once you send a message or peek...

In pursuit of Michael Cassini, "the king of con"
Feb 21, 2006
Post comments count 0
Post likes count 0

In pursuit of Michael Cassini, "the king of con"

Raymond Chen
Raymond Chen

Michael Cassini used forged documents to pretend that he was a Microsoft millionaire and managed to con people out of over $4.5 million before he was finally caught. Cassini claimed a net worth of $12.3 million, an annual income of $700,000; $8 million on account at Barclays Bank, and more. It was all right there on paper. And it was a complete lie, numbers plucked from the air, court records show. (Wow, $700,000, putting him in the nearly same range as Bill Gates, Steve Ballmer, and Jim Allchin, who in 2003 each earned approximately $850,000 in combined salary and bonuses.) The Seattle Times...

How the study of languages influences one's appreciation of international competition
Feb 20, 2006
Post comments count 0
Post likes count 0

How the study of languages influences one's appreciation of international competition

Raymond Chen
Raymond Chen

One of the consequences of studying another language for me is that I develop some sort of mental connection with the people who speak that language, despite having no innate cultural basis for it. When I studied German, I found myself cheering for the German athletes in the Olympic Games. And in the men's 4x10,000 cross-country relay yesterday, I was cheering for the German team, the Swedish team, and the Norwegian team (especially the Norwegians), but it was all for naught as the Italians proved too much for all of them. (Yes, I haven't started studying Norwegian yet, but, as my Swedish readers already know...

Why does my program run faster if I click and hold the caption bar?
Feb 20, 2006
Post comments count 0
Post likes count 0

Why does my program run faster if I click and hold the caption bar?

Raymond Chen
Raymond Chen

Sometimes, people discover that a long-running task runs faster if you hold down the mouse. How can that be? This strange state of affairs typically results when a program is spending too much time updating its progress status and not enough time actually doing work. (In other words, the programmer messed up badly.) When you click and hold the mouse over the caption bar, the window manager waits for the next mouse message so it can determine whether you are clicking on the caption or attempting to drag. During this waiting, window painting is momentarily suppressed. That's why the program runs faster: No win...

Diving into kernel mode with Doron
Feb 17, 2006
Post comments count 0
Post likes count 0

Diving into kernel mode with Doron

Raymond Chen
Raymond Chen

My colleague Doron Holan has started writing about kernel mode driver programming, and it looks like he's jumping in with both feet. I have to admit that I don't understand what he's saying (not being a kernel-mode person myself), but I can assure you that he knows what he's talking about. (Note that he's writing about driver programming, so if you're just looking for an XYZ driver, he won't be able to help you. On the other hand, if you are writing the XYZ driver, then the information he has may prove useful after all.) Even though I've known Doron for several years, I think we've met face-to-face a total of ...

Not all team integrations go smoothly
Feb 17, 2006
Post comments count 0
Post likes count 1

Not all team integrations go smoothly

Raymond Chen
Raymond Chen

When writing the entry on Windows Integration Meetings, I was reminded of a team integration that didn't go quite so smoothly. I will not identify the teams involved because this is not an outlet for finger-pointing but rather a cautionary tale for managers and developers everywhere. Once upon a time, there were two teams developing projects that ended up converging and solving roughly the same problem, but approaching it from different angles. Let's call them Project A and Project 1. The head of the division that was responsible for both of these projects looked at the situation and said, "Well, now ...