The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

Nov 5, 2013
Post comments count 0
Post likes count 1

What is the point of FreeLibraryAndExitThread?

Raymond Chen

The function seems pointless. I mean, all the function does is Who needs such a trivial function? If I wanted to do that, I could just write it myself. And then you discover that occasionally your program crashes. What's going on? Let's rewind and look at the original problem. Originally, you had code that did something like this: This worked great, until somebody did this to your DLL: This code fragment calls your function and then immediately unloads the DLL, presumably because all they wanted to do was call that one function. Now you have a problem: That call frees your DLL, while your i...

Nov 4, 2013
Post comments count 0
Post likes count 1

The complexity of modern voting, or at least modern dream voting

Raymond Chen

I dreamed that I arrived at my polling station just before it closed, but the ballot was not what I expected. Instead of voting on political candidates or referenda, I was voting on music from the 1980's. I ended up voting for an Anne Murray song because it was the only one I recognized, and it wasn't a bad song.

Nov 4, 2013
Post comments count 0
Post likes count 1

Manipulating the zone identifier to specify where a file was download from

Raymond Chen

When you download a file via Internet Explorer, the file is tagged with a little bit of information known as a zone identifier which remembers where the file was downloaded from. This is what tells Explorer to put up the "Yo, did you really want to run this program?" prompt and which is taken into account by applications so that they can do things like disable scripting and macros when they open the document, just in case the file is malicious. Today's Little Program is really three Little Programs: One to read the zone identifier, one to set the zone identifier, and one to clear it. The first program takes...

Nov 1, 2013
Post comments count 0
Post likes count 1

On the various ways of getting the current time and date in Win32

Raymond Chen

There are a number of functions in Win32 that obtain the current date and time. Here's how they fit together: The starting point is . This returns the current time in UTC in the form of a structure. This also happens to be the time format used internally by the system, so this value can be retrieved with a minimum of fuss. You can also call which returns the current UTC time in the form of a structure. To do this, the operating system takes the current and then calls the moral equivalent of , which does a boatload of gnarly math to decompose the into year, month, day, hour, minute, second, and milliseco...

Oct 31, 2013
Post comments count 0
Post likes count 1

The guide to trading candy

Raymond Chen

Important information to know this evening.

Oct 31, 2013
Post comments count 0
Post likes count 1

If there is no 16-bit emulation layer in 64-bit Windows, how come certain 16-bit installers are allowed to run?

Raymond Chen

Because they are emulated.

Oct 30, 2013
Post comments count 0
Post likes count 1

Distinguishing between asking for help with a product and asking for help with a product's installation

Raymond Chen

Internally at Microsoft, we have a programmer's tool which I will call Program Q. On the peer-to-peer mailing list for Program Q, somebody asked the following question: What's the best way to look at all tables created in the past week? I want to repeat this command across multiple table repositories. Somebody chimed in with the answer. You are looking for something like . If you want to repeat across multiple table repositories, you would say , replacing with the table repository server name. This seemed to work, but there was a follow-up question: What's the best way to get the repository se...

Oct 29, 2013
Post comments count 0
Post likes count 1

Help me optimize this code which enumerates all possible GUIDs

Raymond Chen

Um, not really.

Oct 28, 2013
Post comments count 0
Post likes count 1

The financial acumen of sea turtles

Raymond Chen

I dreamed that I was attending some sort of "how to be awesome" seminar where the presenter said, among other things, that a sea turtle, when left to thrive undisturbed, amasses $1 million in personal wealth within one year.