The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

Watching the game of Telephone play out in five seconds
Nov 26, 2010
Post comments count 0
Post likes count 0

Watching the game of Telephone play out in five seconds

Raymond Chen
Raymond Chen

Some time ago, I spent the Thanksgiving holiday with my nieces (ages 3 and 5 at the time), and I overheard this conversation between them. "Thanksgiving is over." — Christmas is coming! "It's Christmas time!" — Today is Christmas!

The easy way out is to just answer the question: What is the current Explorer window looking at?
Nov 26, 2010
Post comments count 0
Post likes count 0

The easy way out is to just answer the question: What is the current Explorer window looking at?

Raymond Chen
Raymond Chen

A customer had the following question: We have an application which copies and pastes files. Our problem is that we want to paste the files into the folder which corresponds to the currently active Windows Explorer window. Right now, we're using , but we find this method unsatisfactory because we want to replace Explorer's default file copy engine with our own custom one. Can you provide assistance? (And commenter wtroost had no clue why somebody would copy a file by sending window messages to Explorer. Well here you have it.) The easy way out is to answer the question: You can enumerate the active Explorer ...

What if two programs did this? Practical exam
Nov 25, 2010
Post comments count 0
Post likes count 0

What if two programs did this? Practical exam

Raymond Chen
Raymond Chen

A customer who doesn't read this blog had the following question: The requirement for our application is that it must be on top of all other windows, even in the presence of other windows with the topmost style. In our and messages, we set ourselves to topmost, and then call to bring ourselves to the front, and then we ourselves just to make sure. The result is that our application and another application end up fighting back and forth because both applications are applying similar logic to remain on top. There are other applications that defeat our logic, and they manage to cover our application. (These ...

You can filter the Common File dialog with wildcards
Nov 24, 2010
Post comments count 0
Post likes count 0

You can filter the Common File dialog with wildcards

Raymond Chen
Raymond Chen

A customer reported an apparent inconsistency in the shell common file dialogs: The question mark appears to be treated differently from other invalid file name characters. I tried to save a file in Paint under the name but instead of telling me that I had an invalid character in the file name (as it does with other characters like and ) or navigating to a new folder (like or ), it appears to do nothing. Actually, it did do something. You just couldn't tell because the result of that something was the same as doing nothing. If you type a wildcard like or into a common file dialog, the dialog interprets ...

But who's going to set up their own email server?
Nov 23, 2010
Post comments count 0
Post likes count 1

But who's going to set up their own email server?

Raymond Chen
Raymond Chen

Many many years ago, back in the days when Microsoft's email address had exclamation points, an internal tool was developed to permit Microsoft employees to view and update their Benefits information from the comfort of their very own offices. Welcome to the paperless office! One of my friends noticed an odd sentence in the instructions for using the tool: "Before running the program, make sure you are logged onto your email server." "That's strange," my friend thought. "Why does it matter that you're logged onto your email server? This tool doesn't use email." Since my friend happened at the time to be a test...

Consequences of using variables declared __declspec(thread)
Nov 22, 2010
Post comments count 0
Post likes count 1

Consequences of using variables declared __declspec(thread)

Raymond Chen
Raymond Chen

As a prerequisite, I am going to assume that you understand how TLS works, and in particular how variables work. There's a quite thorough treatise on the subject by Ken Johnson (better known as Skywing), who comments quite frequently on this site. The series starts here and continues for a total of 8 installments, ending here. That last page also has a table of contents so you can skip over the parts you already know to get to the parts you don't know. Now that you've read Ken's articles... No, wait I know you didn't read them and you're just skimming past it in the hopes that you will be able to fake your ...

What's the difference between the Windows directory and the System directory?
Nov 19, 2010
Post comments count 0
Post likes count 0

What's the difference between the Windows directory and the System directory?

Raymond Chen
Raymond Chen

(Windows was released on November 20, 1985, twenty-five years ago tomorrow. Happy birthday!) You have and you have . Why do we need both? They're both read-only directories. They are both searched by . They seem to be redundant. (There are other directories like which are not relevant to the discussion.) Back in the old days, the distinction was important. The Windows directory was read-write, and it's where user configuration settings were kept. See for example, , which reads from in the Windows directory, and , which defaults to the Windows directory if you don't give a full path to the configuration file....

One possible reason why ShellExecute returns SE_ERR_ACCESSDENIED and ShellExecuteEx returns ERROR_ACCESS_DENIED
Nov 18, 2010
Post comments count 0
Post likes count 0

One possible reason why ShellExecute returns SE_ERR_ACCESSDENIED and ShellExecuteEx returns ERROR_ACCESS_DENIED

Raymond Chen
Raymond Chen

(The strangely-phrased subject line is for search engine optimization.) A customer reported that when they called , the function sometimes fails with , depending on what they are trying to execute. (If they had tried they would have gotten the error .) After a good amount of back-and-forth examing file type registrations, a member of the development team had psychic insight to ask, "Are you calling it from an MTA?" "Yes," the customer replied. "ShellExecute is being called from a dedicated MTA thread. Would that cause the failure?" Why yes, as a matter of fact, and it's called out in the documentation for ....

How full does a hard drive have to get before Explorer will start getting concerned?
Nov 17, 2010
Post comments count 0
Post likes count 0

How full does a hard drive have to get before Explorer will start getting concerned?

Raymond Chen
Raymond Chen

The answer depends on which "hard drive almost full" warning you're talking about. Note that these boundaries are merely the current implementation (up until Windows 7). Future versions of Windows reserve the right to change the thresholds. The information provided is for entertainment purposes only. The thermometer under the drive icon in My Computer uses a very simple algorithm: A drive is drawn in the warning state when it is 90% full. The low disk space warning balloon is more complicated. The simplified version is that it warns of low disk space on drives bigger than about 3GB when free disk space dr...