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

Your program assumes that COM output pointers are initialized on failure; you just don't realize it yet

We saw last time that the COM rules for output pointers are that they must be initialized on return from a function, even if the function fails. The COM marshaller relies on this behavior, but then again, so do you; you just don't realize it yet. If you use a smart pointer library (be it ATL or boost or whatever), you are still relying on output pointers being when not valid, regardless of whether or not the call succeeded. Let's look at this line of code from that article about : If the method puts a non- value in on failure, then when is destructed, it's going to call on itself, and something bad ha...

2009 year-end link clearance

Time for the semi-annual link clearance. And, as always, the obligatory plug for my column in TechNet Magazine:

Why does COM require output pointers to be initialized even on failure?

One of the rules of COM is that if a parameter is marked as an output pointer, then you have to initialize the thing it points to, even if your function failed and you have nothing to return. For example, we saw the problems that can occur if you forget to set the output pointer to in the method. Why does COM have this rule? Doesn't it know that a failure is a failure? Because there are failures and there are sort-of failures. A function can return an error code despite having partially succeeded. For example, if a function receives a buffer that is too small to hold all the data that is available, it might ...

Join the Seattle Symphony for a New Year Eve's performance of Beethoven's Nin… wait a second…

One of the regular events of the Seattle Symphony season is a New Year's Eve late night performance of Beethoven's Ninth Symphony followed by a post-concert party to ring in the new year. Last year I received an advertisement in the mail promoting that year's concert, and one page of the brochure contained the message {Ring in the New Year} printed atop a photo of an impressive array of musical forces crammed onto the Benaroya Hall stage. But if you look closely at the instruments being played and the composition of the chorus, you quickly realize that they aren't performing Beethoven's Ninth Symphony. Beethoven...

Even your folder icons can be used as a Rorschach test

Jenny Lam (now at Jackson Fish Market) forwarded me this picture of a USB thumb drive. She also reminded me of another one of those Windows as Rorschach test incidents that surrounded the Windows Vista folder icons. It was reported during one of the betas that the 16×16 folder icon looked like someone flipping the bird. Sure, this interpretation required some creativity, and it perhaps reflects more on the person making the observation than on the folder icon itself, but the report still had to be taken seriously, because one thing you don't want is a newspaper headline saying that your product uses c...

How do I minimize a group of windows in Windows 7 from the taskbar?

The Windows 7 taskbar automatically groups similar windows, and when you right-click on the grouped icon, you may get fancy stuff like a jump list or a task list, but you will also get a very small repertoire of window management options. In particular, the only option that operates on the group is Close all windows. What about the other group options? To get a list of more group window options, hold the shift key when you right-click on the grouped icon. Then you'll get more options like Cascade and Minimize all windows. Since the contents of the regular right-click pop-up window are dynamic, when you hit...

How does the keyboard autorepeat setting work?

Commenter eric johnson wonders how that control panel keyboard autorepeat setting works. This is one of those questions that has many answers, depending on how deep you want to dig. The first layer of the question is how the control panel changes the keyboard autorepeat rate. That's simple: It uses . From the documentation, you can see that the keyboard speed is an integer in the range 0..31, where 0 indicates 2 characters per second and 31 indicates approximately 30 characters per second. The next layer of the question is why the expresses the keyboard autorepeat setting in a 0..31 range, and why the upper ...

Merry Christmas to me: Zune headphones

My article some time back about accidentally destroying my beloved Zune headphones resulted in a number of people sending me their unwanted Zune headphones via inter-office mail. This was not my intention when I posted the article—if that were my goal, I would have posted the article immediately instead of waiting a year and a half!—but it was nevertheless a pleasant surprise. Every so often strangers come through. Thanks, everybody.

No, you didn't win the Jethro Tull box set, and please tell everybody else in your area code to stop calling me

Some time ago, a fellow employee started receiving mysterious fax calls at the office four or five times a day and had to call the Microsoft telephone services folks to block the caller. But this reminded another colleague of a much more annoying problem, and one for which caller-block would not have worked. A local radio station had a contest line in the 206 area code. If someone in the 425 area code dialed this number without dialing the 206 area code prefix, they rang the phone of a new Microsoft employee. That employee's phone was set up incorrectly, and the calls ended up auto-forwarded to my phone. Every ...