The Old New Thing
Practical development throughout the evolution of Windows.
Latest posts
What does 1#J mean? A strange corner case of the printing of special values
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...
Is there a way to specify an icon to appear next to a menu item via the resource template?
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!
When the option becomes so second-nature you forget that it’s an option
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)...
This code would be a lot faster if it weren’t for the synchronization
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...
Dreaming up strange inventions: The combination urinal/bidet/washing machine
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."
Display a custom thumbnail for your application (and while you’re at it, a custom live preview)
Mini-me.
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?
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...
Isn’t the CompletionKey parameter to CreateIoCompletionPort superfluous?
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-...
What does -1.#IND mean?: A survey of how the Visual C runtime library prints special floating point values
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...