The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

Mar 26, 2007
Post comments count 0
Post likes count 0

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

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...

Mar 26, 2007
Post comments count 0
Post likes count 1

Passing by address versus passing by reference, a puzzle

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:...

Mar 23, 2007
Post comments count 0
Post likes count 0

The wisdom of seventh graders and you: Design a course

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...

Mar 23, 2007
Post comments count 0
Post likes count 1

Excursions in composition: Adding rewind support to a sequential stream

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 ...

Mar 22, 2007
Post comments count 0
Post likes count 1

Excursions in composition: Sequential stream concatenation

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 ...

Mar 21, 2007
Post comments count 0
Post likes count 1

You don't know what you do until you know what you don't do

Raymond Chen

Many years ago, I saw a Dilbert cartoon that went roughly like this. Frame 1: Supertitle - "Dogbert's guide to project management." Frame 2: Supertitle - "Not a project." Dilbert answers the phone. "Sure, we do that." Frame 3: Supertitle - "A project." Dilbert answers the phone. "No, we don't do that."† I've seen a lot of software projects, and one thing I've learned is that you don't have a product until you start saying "No". In the early phases of product design, you're all giddy with excitement. This new product will be so awesome. It will slice bread. It will solve world hunger. It's designed for ever...

Mar 20, 2007
Post comments count 0
Post likes count 0

The early stages of Joshua Roman groupie-dom

Raymond Chen

The first time I saw the Seattle Symphony's new principal cellist Joshua Roman, it was at a subscription performance of Mahler's Seventh Symphony in June 2006, shortly after the then-22-year-old took the principal's seat from the retiring Raymond Davis. We noticed that there was a new face in the orchestra, and wondered afterwards, "Who was that floppy-haired kid?" Well, we now know who that floppy-haired kid is, and he's taking Seattle by storm. Our symphony group's seats this season are up close, and it's such a pleasure watching Joshua Roman play, seeing him check in with the other string principals periodi...

Mar 20, 2007
Post comments count 0
Post likes count 1

I bet somebody is looking to get a really nice bonus for that feature: Uninstall

Raymond Chen

A customer asked the following question (paraphrased): Does the Windows XP Add/Remove Programs control panel expose a scriptable object model? We want our program to open the Add/Remove Programs control panel and uninstall the programs of our competitors. No, there is no object model for the Add and Remove Programs control panel, and it frightens me that you're even contemplating what you're suggesting.

Mar 19, 2007
Post comments count 0
Post likes count 1

How do the menu functions find items?

Raymond Chen

Most of the menu item functions such as allow you specify the menu item either by position or by command. Some of them use the and flags. Others separate the search algorithm into a separate flag. Searching for menu items by position is straightforward: The specified position is used as a zero-based index into the menu. In other words, the first item in the menu is item zero. Searching for menu items by command is trickier. The menu manager searches the entire menu hierarchy, including submenus, for an item with the command you specify. If more than one menu item has the identifier you requested, then one o...