The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

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

What does 1#J mean? A strange corner case of the printing of special values

Raymond Chen

As a puzzle, commenter nobugz asks, "What kind of infinity is 1.#J?" double z = 0; printf("%.2f", 1/z); Now, the division by zero results in IEEE positive infinity, would would normally be printed as 1#INF. But the catch here is that the print format says "Display at most two places after the decimal point." But where is the decimal point in infinity? The Visual C runtime library arbitrarily decided that all of the exceptional values have one digit before the decimal (namely, the "1"). Actually, it turns out that this puzzle might be an answer to Random832's question, "What's the 1 for?" Maybe the 1 is the...

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

Is there a way to specify an icon to appear next to a menu item via the resource template?

Raymond Chen

The structure lets you specify a bitmap to appear next to the menu item. Is there a way to do this from a menu resource template? No. If you look at the format of menu templates, you'll see that there is nowhere to specify a bitmap. Which kind of makes sense, because it is the responsibility of the application to destroy the bitmap referenced by the member when the menu is destroyed, but if you created the menu from a template, you don't know what that handle is, so you can't destroy it either!

Feb 27, 2013
Post comments count 0
Post likes count 1

When the option becomes so second-nature you forget that it’s an option

Raymond Chen

A user of the imaginary Program Q program wanted to write an automated test that created a table, then ran various sub-test which communicated among each other by updating that table. When my test tries to create a table, the program asks the following question: q install server -r testdb Setting up this machine to be a registered table server... Registered table servers must adhere to Microsoft information security policies. See http://programq/policy for details. If you have questions, contact mailto:qpolicy. Do you agree to adhere to Microsoft policies regarding registered table servers (y/n/q)...

Feb 26, 2013
Post comments count 0
Post likes count 1

This code would be a lot faster if it weren’t for the synchronization

Raymond Chen

This is a story from a friend of a friend, which makes it probably untrue, but I still like the story. One of my colleagues jokingly suggested that we could speed up our code by adding these lines to our project #define EnterCriticalSection(p) ((void)0) #define LeaveCriticalSection(p) ((void)0) I replied, "You think you're joking, but you're not." According to legend, there was a project whose product was running too slow, so they spun off a subteam to see what architectural changes would help them improve their performance. The subteam returned some time later with a fork of the project that they had "t...

Feb 25, 2013
Post comments count 0
Post likes count 1

Dreaming up strange inventions: The combination urinal/bidet/washing machine

Raymond Chen

I dreamed that a friend of mine was showing me her new appliance: A combination urinal/bidet/washing machine. As we loaded clothes into it, she said, "You okay in there, Stephanie?" A muffled voice emerged from within: "Just let me know when you're ready."

Feb 25, 2013
Post comments count 0
Post likes count 1

Display a custom thumbnail for your application (and while you’re at it, a custom live preview)

Raymond Chen

Mini-me.

Feb 22, 2013
Post comments count 0
Post likes count 0

Now that version 4 of the .NET Framework supports in-process side-by-side runtimes, is it now okay to write shell extensions in managed code?

Raymond Chen

Many years ago, I wrote, "Do not write in-process shell extensions in managed code." Since I originally wrote that article, version 4 of the .NET Framework was released, and one of the features of that version is that it supports in-process side-by-side runtimes. Does that mean that it's now okay to write shell extensions in managed code? The answer is still no. The Guidance for implementing in-process extensions has been revised, and it continues the recommendation against writing shell extensions and Internet Explorer extensions (and other types of in-process extensions) in managed code, even if you're us...

Feb 22, 2013
Post comments count 0
Post likes count 1

Isn’t the CompletionKey parameter to CreateIoCompletionPort superfluous?

Raymond Chen

When you associate a file handle with an I/O completion port with the function, you can pass an arbitrary pointer-sized integer called the which will be returned by the function for every I/O that completes against that file handle. But isn't that parameter superfluous? If somebody wanted to associated additional data with a file handle, they could just extend the structure to contain that additional data. Yes, they could, so in a purely information-theoretical sense, the parameter is superfluous. And heated seats in your car are superfluous, too. But they sure are nice! From a purely information-...

Feb 21, 2013
Post comments count 0
Post likes count 1

What does -1.#IND mean?: A survey of how the Visual C runtime library prints special floating point values

Raymond Chen

As every computer scientist knows, the IEEE floating point format reserves a number of representations for infinity and non-numeric values (collectively known as NaN, short for not a number). If you try to print one of these special values with the Visual C runtime library, you will get a corresponding special result: Positive and negative infinity are generated by arithmetic overflow, or when the mathematical result of an operation is infinite, such as taking the logarithm of positive zero. (Don't forget that IEEE floating point supports both positive and negative zero.) For math nerds: IEEE arithmetic uses...