Things I’ve written that have amused other people, Episode 8

In a technical discussion, I opened a reply with Bob’s paper which I haven’t yet read points out that… Some people wrote to me to say that the’ve added this quote to their file in the hopes of being able to use it themselves someday. For those who are curious, I found the technical discussion…


Why is CLIPFORMAT defined to be a WORD rather than a UINT?

Commenter Ivo wants to know if the Register­Clipboard­Format function returns a UINT, why is the CLIP­FORMAT data type defined to be a WORD? Since a WORD is smaller than a UINT, you have to stick in a cast every time you assign the result of Register­Clipboard­Format to a CLIP­FORMAT. Rewind to 16-bit Windows. Back in…


How to insert a large number of items into a treeview efficiently

Just a quick tip today. If you need to insert a large number of items into a treeview, like tens of thousands, then it’s much more efficient to insert them “backwards”. (I’m ignoring for now the usability question of having a treeview that large in the first place.) In other words, instead of for (i…


How can I extend the deadline for responding to the PBT_APMSUSPEND message?

A customer observed that starting in Windows Vista, the deadline for responding to the PBT_APMSUSPEND message was reduced from twenty seconds to two seconds. Their program needs more than two seconds to prepare for a suspend and they wanted to know how they could extend the deadline. The program communicates with a device, and if…


It is not unreasonable to expect uninitialized garbage to change at any time, you don’t need to ask for an explanation

A customer admitted that they had a bug in their code: #define UNICODE #define _UNICODE #include <windows.h> // error checking removed for expository purposes // code that writes out the data RegSetValueEx(hkey, pszValue, 0, REG_SZ, (const BYTE *)pszData, _tcslen(pszData) * sizeof(TCHAR) + 1); // code that reads the data DWORD dwType, cbData; RegQueryValueEx(hkey, pszValue, NULL,…


The Control Panel search results understand common misspellings, too

Here’s a little trick. Open your Start menu and type scrensaver into the search box. That’s right, spell it with only one e. Hey, it still found the Control Panel options for managing your screen saver. If you enable Improve my search results by using online Help in Windows Help and Support, this sends your…


Why not use animated GIFs as a lightweight alternative to AVIs in the animation common control?

Commenter Vilx- wondered why animated GIFs weren’t used as the animation format for the shell animation common control. After all, “they are even more lightweight than AVIs.” Animated GIFs are certainly more lightweight than general AVIs, since AVI is just a container format, so decoding a general AVI means decoding any encoding format invented now…


Why can’t I install this DLL via Regsvr32 /i?

A customer asked for help installing a particular DLL. They ran the command regsvr /i SomeDll.dll but got the error “SomeDll.dll was loaded, but the DllInstall entry point was not found. This file can not be registered.” A DLL needs to be specifically written to be used with the regsvr32 command. You can’t just grab…