The Old New Thing

What's so special about the desktop window?

The window returned by GetDesktopWindow() is very special, and I see people abusing it all over the place. For example, many functions in the shell accept a window handle parameter to be used in case UI is needed. IShellFolder::EnumObjects, for example. What happens if you pass GetDesktopWindow()? If UI does indeed need to be ...

Invalid thread and process IDs

Perhaps you want a value to use as a sentinel, which you want to be guaranteed is never a valid thread ID or process ID. What values can you use? Nothing is explicitly written about this topic, but you can put on your logic cap and figure it out. If you need an invalid thread ID, you can use zero. How do you know that zero is an ...

Raymond's comment policy

Okay, I was hoping it wasn't going to be needed but it takes only one bad apple... Here are the ground rules. Things that increase the likelihood that your comment will be edited or deleted: If a wave of comment spam is under way, I may choose to moderate or even close comments until the problem subsides. More rules may be added later...

Why do I get a QueryInterface(IID_IMarshal) and then nothing?

A common problem when trying to get your new COM object off the ground is that you can't seem to be able to get it created. The object comes out of the class factory, and it gets a QueryInterface for IMarshal, and then nothing. What's going on? This is a sure sign that you didn't register your CLSID properly; most likely you forgot to ...

Sorry the posts are late lately

Somehow the server is in a wonky state and my autopilot script that posts a new article at 7 every morning is getting error 500 back (internal server error). So I'm posting manually for the nonce. Expect erratic posting times until the problem is resolved...

No code is an island

Norman Diamond noted in a comment that on Windows 2003 Server, the Display Adapter Troubleshooting slider still lists "full acceleration" as the recommended setting even though the default for Server is "full minus one". This is one of those "Oh, that's an easy change" bugs. The discussion probably went like this: Some guy whose idea ...

Why are RECTs endpoint-exclusive?

Endpoint-exclusive RECTs and lines are much easier to work with. For example, the width of a rectangle is , and its height is . If rectangles were endpoint-inclusive, then there would be annoying +1's everywhere. End-point exclusive rectangles also scale properly. For example, suppose you have two rectangles (0,0)-(100,100) and (100,100)-(...

The social skills of a thermonuclear device

Somebody@somewhere.else described me as having the social skills of a thermonuclear device. I don't remember the incident in question, but I'll have to accept that it happened. I have a very low tolerance for laziness. If you come to me for help, I expect you to have done your homework. (Though I try to scale my expectations to your position...