The Old New Thing
Practical development throughout the evolution of Windows.
Latest posts

Around and around and back and somewhere else

I dreamed that I was navigating through an enormous house, with lots of twists and turns. I eventually became convinced that the house was only locally Euclidean. Yes, I sometimes have topology dreams.

Marking a shortcut to say that it should not be placed on the Windows 8 Start page upon installation or treated as a newly-installed application

Today's Little Program creates a shortcut on the Start menu but marks it as "Do not put me on the front page upon installation." This is something you should do to any secondary shortcuts your installer creates. And while you're at it, you may as well set the "Don't highlight me as a newly-installed program" attribute used by Windows 7. (Remember, Little Programs do little to no error checking.) #define UNICODE #define _UNICODE #define STRICT #include <windows.h> #include <shlobj.h> #include <atlbase.h> #include <propkey.h> #include <shlwapi.h> int __cdecl wmain(int, wchar_t...

The source of much confusion: “backed by the system paging file”

Perhaps one of the most misunderstood sentences in the Win32 documentation is this little bit in the documentation for : If hFile is INVALID_HANDLE_VALUE, the calling process must also specify a size for the file mapping object in the dwMaximumSizeHigh and dwMaximumSizeLow parameters. In this scenario, CreateFileMapping creates a file mapping object of a specified size that is backed by the system paging file instead of by a file in the file system. When people read the underlined portion, they interpret this to mean "The data in the file mapping object will be written to the ...

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.