The Old New Thing

The macros for declaring and implementing COM interfaces

There are two ways of declaring COM interfaces, the hard way and the easy way. The easy way is to use an IDL file and let the MIDL compiler generate your COM interface for you. If you let MIDL do the work, then you also get __uuidof support at no extra charge, which is a very nice bonus. The hard way is to do it all by hand. If you ...

Sometimes the bug isn’t apparent until late in the game

I didn't debug it personally, but I know the people who did. During Windows XP development, a bug arrived on a computer game that crashed only after you got to one of the higher levels. After many saved and restored games, the problem was finally identified. The program does its video work in an offscreen buffer and transfers it to ...

Why does Windows keep your BIOS clock on local time?

Even though Windows NT uses UTC internally, the BIOS clock stays on local time. Why is that? There are a few reasons. One is a chain of backwards compatibility. In the early days, people often dual-booted between Windows NT and MS-DOS/Windows 3.1. MS-DOS and Windows 3.1 operate on local time, so Windows NT ...

Importance of alignment even on x86 machines, part 2

The various Interlocked functions (InterlockedIncrement, and so on) require that the variable being updated be properly aligned, even on x86, a platform where the CPU silently fixes unaligned memory access invisibly. If you pass an unaligned pointer to one of the Interlocked functions, the operation will still succeed, but the result won't ...

Importance of alignment even on x86 machines

Sometimes unaligned memory access will hang the machine. Some video cards do not let you access all the video memory at one go. Instead, you are given a window into which you can select which subset of video memory ("bank") you want to see. For example, the EGA video card had 256K of memory, split into four 64K banks. If you wanted to access...

Why was nine the maximum number of monitors in Windows 98?

Windows 98 was the first version of Windows to support multiple monitors. And the limit was nine. Why nine? Because that allowed you to arrange your monitors like this. You have early seventies television to thank. [Raymond is currently on vacation; this message was pre-recorded...