The Old New Thing

What does an invalid handle exception in LeaveCriticalSection mean?

Internally, a critical section is a bunch of counters and flags, and possibly an event. (Note that the internal structure of a critical section is subject to change at any time—in fact, it changed between Windows XP and Windows 2003. The information provided here is therefore intended for troubleshooting and debugging purposes...

Throwing things into a blender and seeing what happens

Manufacturer of commercial and home blenders Blendtec has produced a marketing web site Will It Blend? which features short videos of the company's CEO and new Internet blending icon Tom Dickson throwing all sorts of unusual objects into one of their blenders, to see what happens. (The videos are also on YouTube, and of course they have a ...

Do not overload the E_NOINTERFACE error

One of the more subtle ways people mess up is returning when the problem wasn't actually an unsupported interface. The return value has very specific meaning. Do not use it as your generic "gosh, something went wrong" error. (Use an appropriate error such as or .) Recall that the rules for are that (in the absence of catastrophic errors...

The wisdom of seventh graders: What to do with a time machine (part 3)

(Continuing from part 2.) Here are more sentences from seventh grade time travel essays. Remember, these sentences are not representative of seventh grade writing in general; these are just the funny bits. World History The Future: Most students who travelled to the future wanted to meet themselves. Letter Format: Some students took ...

If you let people read a file, then they can copy it

Here's a question that floated past my view: How do I set the ACLs on a file so users can read it but can't copy it? I can't find a "Copy" access mask that I can deny. If I can't deny copying, I'd at least like to audit it, so I can tell who made a copy of the file. There is no "Copy" access mask because copying is not a fundamental file ...

The wisdom of seventh graders: What to do with a time machine (part 2)

(Make sure you've read Part 1 for background information.) On the subject of where they would go in a time machine, many students wrote well-thought-out essays, beautifully composed. These sentences below did not come from those essays. I've categorized the snippets roughly by theme, though I had to guess at some of them since the ...

How do I find all files with at least one space in their name?

You already know how to do this, you just don't realize it. How do you find files with an "x" in their name? That's right, you use . Now you just have to change that x to a space. And since spaces are command line delimiters, you need to quote the sequence so it gets treated as a single parameter rather than two "*" parameters: Stick ...

The wisdom of seventh graders: What to do with a time machine (part 1)

All the students at a local school were asked to composed an in-class essay on the following topic: "Your science teacher has invented a time machine. You have been selected to take the first trip. Explain in a multi-paragraph letter to your teacher where you will go and why." (Students were given two hours, plus one additional hour upon ...