The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

Beverage Gas Division of Central Welding Supply
Mar 23, 2012
Post comments count 0
Post likes count 0

Beverage Gas Division of Central Welding Supply

Raymond Chen
Raymond Chen

The other day, I saw a van which was labeled Beverage Gas Division of Central Welding Supply. This odd juxtaposition was created by the acquisition of Compressed Gas Western by Central Welding Supply in 2009. I sure hope they don't get their tanks confused.

Why is the Heap32Next function incredibly slow on Windows 7?
Mar 23, 2012
Post comments count 0
Post likes count 0

Why is the Heap32Next function incredibly slow on Windows 7?

Raymond Chen
Raymond Chen

Improved correctness but at a price.

Why does my window style change when I call SetWindowText?
Mar 22, 2012
Post comments count 0
Post likes count 0

Why does my window style change when I call SetWindowText?

Raymond Chen
Raymond Chen

A customer observed some strange behavior with window styles: We ran some weird behavior: Calling the function causes a change in window styles. Specifically, calling results in the and messages, and sometimes the result is that the style is removed. Is this a bug? What would cause this? The message sends the message to the control, at which point anything that happens is the window's own responsibility. If it wants to change styles based on the text you sent, then that's what happens. The window manager doesn't do anything special to force it to happen or to prevent it. That's weird, because I'm not e...

Isn't there a race condition in GetFileVersionInfoSize?
Mar 21, 2012
Post comments count 0
Post likes count 0

Isn't there a race condition in GetFileVersionInfoSize?

Raymond Chen
Raymond Chen

In response to my explanation of what the parameter in is used for, Steve Nuchia wonders if there's a race condition between the time you get the size and the time you ask for the data. Yes, there is a race condition, but calling the function in a loop won't help because the function does not report that the buffer is too small to hold all the version data. It just fills the buffer as much as it can and truncates the rest. In practice, this is not a problem because you are usually getting the versions of files that you expect to be stable. For example, you might be obtaining the version resources of the fi...

In 1993, Microsoft stole my colleague's car
Mar 20, 2012
Post comments count 0
Post likes count 0

In 1993, Microsoft stole my colleague's car

Raymond Chen
Raymond Chen

I remember walking between buildings at Microsoft back in the 1990's and seeing a moss-covered, rusted-out jalopy in one of the parking spaces. It clearly hadn't moved in ages. The person I was with said, "Oh, yeah, Microsoft owns that car. They stole it from Bob." (Bob is my generic name for a Microsoft employee.) The Inaugural Day Storm of 1993 left felled trees and other wind damage in its wake on the Microsoft Redmond campus. One of my colleagues was out of town when the storm hit, and he returned to stories of fallen trees, wind damage, and howling winds. Bob also returned to find that his car had been st...

The most exciting part of my morning is catching my bus, specifically, making the transfer
Mar 19, 2012
Post comments count 0
Post likes count 0

The most exciting part of my morning is catching my bus, specifically, making the transfer

Raymond Chen
Raymond Chen

Note: Transit nerd content. You have been warned. I still rely on One Bus Away to tell me when my bus is coming. Recent changes in bus service means that there is no longer a direct bus from my neighborhood to my work. My basic options are as follows: If you sit and work out the math, the total travel time for all the options is about the same, around 29 minutes. Which is about the same time it takes me to ride my bicycle, so it basically doesn't matter which route I take, especially since traffic lights randomize the travel time by a few minutes each way. But the paradox of choice means that I still try ...

Why does holding the Ctrl key when selecting New Task from Task Manager open a command prompt?
Mar 19, 2012
Post comments count 0
Post likes count 0

Why does holding the Ctrl key when selecting New Task from Task Manager open a command prompt?

Raymond Chen
Raymond Chen

Commenter Adam S wonders why holding the Ctrl key when selecting New Task from Task Manager will open a command prompt. It's a rogue feature. Windows XP introduced visual styles, and one of the tricky parts of debugging visual styles is that if the visual style engine goes berzerk, you can't see anything! One of the problems that the visual styles folks encountered when developing their feature was that sometimes they would get into a state where the Run dialog would stop working. And without a Run dialog, you couldn't install or launch a debugger to begin investigating what went wrong. The solution...

Memory allocation functions can give you more memory than you ask for, and you are welcome to use the freebies too, but watch out for the free lunch
Mar 16, 2012
Post comments count 0
Post likes count 0

Memory allocation functions can give you more memory than you ask for, and you are welcome to use the freebies too, but watch out for the free lunch

Raymond Chen
Raymond Chen

Memory allocation functions like , , , and all have the property that they can return more memory than you requested. For example, if you ask for 13 bytes, you may very well get a pointer to 16 bytes. The corresponding functions return the actual size of the memory block, and you are welcome to use all the memory in the block up to the actual size (even the bytes beyond the ones you requested). But watch out for the free lunch. Consider the following code: So far so good. We allocate some memory, and then fill it with zeroes. That gives us our zero-initialized memory. Or does it? When you ask the hea...

Why does the VerQueryValue function give me the wrong file version number?
Mar 15, 2012
Post comments count 0
Post likes count 0

Why does the VerQueryValue function give me the wrong file version number?

Raymond Chen
Raymond Chen

A customer was writing a test to verify that their patching system was working properly, but they found that even after the patch was installed, a call to reported that the file was still the original version. Why was the function reporting the wrong version? Recall that the version resource is, well, a resource. And one of the things that happens with resources is that they can get redirected based on the language the user is running. When you ask for the resources of a language-neutral DLL, the loader redirects your request to the appropriate language-specific DLL. That way, if you're running on an English ...