The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

The buffer size parameter to GetFileVersionInfo is the size of your buffer, no really
Mar 29, 2007
Post comments count 0
Post likes count 0

The buffer size parameter to GetFileVersionInfo is the size of your buffer, no really

Raymond Chen
Raymond Chen

The function takes a pointer to a buffer () and a size (), and that size is the size of the buffer, in bytes. No really, that's what it is. The application compatibility folks found one popular game which wasn't quite sure what that parameter meant. The programmers must have thought it meant "The size of the version resources you want to load" and called it like this (paraphrased): "Gosh, the function wants to know how big the version info is, so we need to call to find out!" they must have thought. This code worked great... for a while. It was checking the file version of the video driver. (My gues...

The social skills of a thermonuclear device, part 4
Mar 28, 2007
Post comments count 0
Post likes count 0

The social skills of a thermonuclear device, part 4

Raymond Chen
Raymond Chen

Last summer, one of my colleagues thought it would be fun to have an informal "lunch chat with Raymond" as a special treat for our summer interns. One of the interns reacted to the invitation a bit unexpectedly, asking meekly, "Is he going to yell at us?"

Why are there both TBSTYLE_EX_VERTICAL and CCS_VERT?
Mar 28, 2007
Post comments count 0
Post likes count 0

Why are there both TBSTYLE_EX_VERTICAL and CCS_VERT?

Raymond Chen
Raymond Chen

There are two ways to make a vertical toolbar. You can use the common style, or you can use the extended style which is specific to the toolbar. Why are there two ways of doing the same thing? Because we messed up. Whoever created the extended style didn't realize that there was already a perfectly good way of specifying a vertical toolbar (namely, ). What's worse, some vertical behavior is controlled by and some by . So if you want a vertical toolbar, you probably want to set both styles to cover all your bases on Windows XP. Unfortunately, the story doesn't get any better. Once this mistake was dis...

Microspeak: Calibration
Mar 27, 2007
Post comments count 0
Post likes count 0

Microspeak: Calibration

Raymond Chen
Raymond Chen

The publicity machine continues: A chat with Scott Hanselman and Hanselminutes
Mar 26, 2007
Post comments count 0
Post likes count 0

The publicity machine continues: A chat with Scott Hanselman and Hanselminutes

Raymond Chen
Raymond Chen

Scott Hanselman let me know he was going to be in town, and after some negotiation with the company PR department (who probably get the massive heebie-jeebies from this whole blog thing), I was able to accept his invitation to appear on his weekly podcast, HanselMinutes. We sat down for a little chat, and a few weeks later, I became Show #56. I haven't had the nerve to listen to it myself. I hope I came off okay. In other self-promotion news (did I mention yet that I wrote a book?), it looks like I will be in Palo Alto on April 21 for a family event, and I'll likely spend the 20th visiting Microsoft's Sili...

Passing by address versus passing by reference, a puzzle
Mar 26, 2007
Post comments count 0
Post likes count 0

Passing by address versus passing by reference, a puzzle

Raymond Chen
Raymond Chen

Commenter Mike Petry asked via the Suggestion Box: Why can you dereference a COM interface pointer and pass it to a function with a Com interface reference. The call. The function called. I found some code written like this during a code review. It is wrong but it seems to work. You already know the answer to this question. You merely got distracted by the use of a COM interface. Let me rephrase the question, using an abstract C++ class instead of a COM interface. (The virtualness isn't important to the discussion.) Given this code: How is this different from the pointer version? The answer:...

The wisdom of seventh graders and you: Design a course
Mar 23, 2007
Post comments count 0
Post likes count 0

The wisdom of seventh graders and you: Design a course

Raymond Chen
Raymond Chen

I'm out today to volunteer with grading student essays. The topic the students were given is one that I suggested: "You have been chosen to design a new elective for your school. Describe what it would be." In a few weeks, you'll learn what the students wrote, but my question for you is what you would propose in your essay. You can answer the question with the wisdom of adulthood (i.e., what course you would design for seventh graders), or, more challenging, you can describe what sort of course you would have designed if you were given this assignment as a twelve-year-old. (Please specify which category you're s...

Excursions in composition: Adding rewind support to a sequential stream
Mar 23, 2007
Post comments count 0
Post likes count 0

Excursions in composition: Adding rewind support to a sequential stream

Raymond Chen
Raymond Chen

Here's a problem "inspired by actual events": I have a sequential stream that is the response to a request I sent to a web site. The format of the stream is rather messy; it comes with a variable-length header that describes what type of data is being returned. I want to read that header and then hand the stream to an appropriate handler. But the handlers expect to be given the stream in its entirety, including the bytes that I have already read. Since this is a sequential stream, I can't change the seek position. How can I "unread" the data and give the handlers what they want? Right now, I'm just closing ...

Excursions in composition: Sequential stream concatenation
Mar 22, 2007
Post comments count 0
Post likes count 0

Excursions in composition: Sequential stream concatenation

Raymond Chen
Raymond Chen

As we've seen a few times already (when building context menus and exploring fiber-based enumeration), composition is an important concept in object-oriented programming. Today, we're going to compose two sequential streams by concatenation. There really isn't much to it. The idea is to take two streams and start by reading from the first one. When that runs out, switch to reading from the second one. Most of this is just typing. (As usual, I am using plain C++; in real life, you can save yourselves a lot of typing by using a class library of your choosing.) We'll start with a base class that does all the ...