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

How do I get the color depth of the screen?

How do I get the color depth of the screen? This question already makes an assumption that isn't always true, but we'll answer the question first, then discuss why the answer is wrong. If you have a device context for the screen, you can query the color depth with a simple arithmetic calculation: Now that you have the answer, I'll explain why it's wrong, but you can probably guess the reason already. Two words: Multiple monitors. If you have multiple monitors connected to your system, each one can be running at a different color depth. For example, your primary monitor might be running at 32 bits per p...

Why are the keyboard scan codes for digits off by one?

What, they were digits?

Why does each drive have its own current directory?

Commenter Dean Earley asks, "Why is there a 'current directory' AND an current drive? Why not merge them?" Pithy answer: Originally, each drive had its own current directory, but now they don't, but it looks like they do. Okay, let's unwrap that sentence. You actually know enough to answer the question yourself; you just have to put the pieces together. Set the wayback machine to DOS 1.0. Each volume was represented by a drive letter. There were no subdirectories. This behavior was carried forward from CP/M. Programs from the DOS 1.0 era didn't understand subdirectories; they referred to files ...

Why does TaskDialog return immediately without showing a dialog? – Answer

Last time, I left an exercise to determine why the function was not actually displaying anything. The problem had nothing to do with an invalid window handle parameter and had all to do with original window being destroyed. My psychic powers told me that the window's handler called . As we learned some time ago, quit messages cause modal loops to exit. Since the code was calling after the window was destroyed, there was a message still sitting in the queue, and that quit message caused the modal loop in to exit before it got a chance to display anything. Switching to wouldn't have changed anything, si...

Why does my asynchronous I/O request return TRUE instead of failing with ERROR_IO_PENDING?

A customer reported that their program was not respecting the flag consistently: My program opens a file handle in mode, binds it to an I/O completion callback function with , and then issues a against it. I would expect that the returns and returns , indicating that the I/O operation is being performed asynchronously, and that the completion function will be called when the operation completes. However, I find that some percentage of the time, the call to returns , indicating that the operation was performed synchronously. What am I doing wrong? I don't want my thread to block on I/O; that's why I'm issu...

The overlooked computer room at school that became my "office" for a while

VIMH's comment on an unmarked restroom that is largely unknown reminds me of a story from my college days. Since my final project involved computational geometry, I was granted a key to the rooms in our department which had the computers with fancy graphical displays. (The term "fancy graphical display" is a relative one, mind you. By today's standards they would be pretty lame.) Use of the computers in these rooms was normally reserved for faculty and graduate students. During my wanderings through the department building, I discovered that there was a small storage room in an unused corner of the basement tha...

Why does TaskDialog return immediately without showing a dialog?

A customer reported a problem with the function. We've encountered a strange behavior in the function. A user reported that when exiting our application, our program played an error beep that didn't appear to be associated with an error. After investigating, we found that the sound is coming from our application trying to display an error dialog before closing by calling . The error beep is played but no dialog appears. Some background on the error condition that we're trying to report: We're calling , and the window procedure creates another window in its handler. It looks like the original window is dest...

Wildly popular computer game? The Windows product team has you covered

In Windows 95, the most heavily-tested computer game was DOOM. Not because the testers spent a lot of time developing test plans and test harnesses and automated run-throughs. Nope, it was because it was by far the most popular game the Windows 95 team members played to unwind. It was a huge breakthrough when DOOM finally ran inside a MS-DOS box and didn't require booting into MS-DOS mode any more. Now you could fire up DOOM without having to exit all your other programs first. I've learned that in Windows Vista, the most heavily tested game was World of Warcraft. Most members of the DirectX appl...

Secret passages on Microsoft main campus

Getting from one point to another.