The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

Sep 24, 2012
Post comments count 0
Post likes count 1

I brought this process into the world, and I can take it out!

Raymond Chen

Clipboard Gadget wants to know why normal processes can kill elevated processes via , yet they cannot do a trivial . "Only explorer seems to be able to do so somehow." There are several questions packed into this "suggestion." (As it happens, most of the suggestions are really questions; the suggestion is "I suggest that you answer my question." That's not really what I was looking for when I invited suggestions, but I accept that that's what I basically get.) First, why can normal processes kill elevated processes? The kernel-colored glasses answer is "because the security attributes for the process grants ...

Sep 21, 2012
Post comments count 0
Post likes count 0

In vollen Zügen genießen

Raymond Chen

One of my friends bought me a souvenir one one of his trips to Germany. It is a beer mug from Bayerischer Bahnhof, a restaurant and brewery at the Leipzig Bayerischer Bahnhof. The mug carries the brewery's slogan In vollen Zügen genießen, which is a German idiom meaning "to enjoy to the fullest." Literally, "Das Leben in vollen Zügen genießen" means "to enjoy life in full gulps", the idea being that instead of sipping your way through life, you're taking huge gulps of it. The slogan is a pun, though, for the Bayerischer Bahnhof, because the word Zug also means train. They come from the roo...

Sep 21, 2012
Post comments count 0
Post likes count 1

How can I implement SAFEARRAY.ToString() without going insane?

Raymond Chen

A colleague needed some help with manipulating s. I have some generic code to execute WMI queries and store the result as strings. Normally, does the work, but doesn't know how to convert arrays (e.g. ). And there doesn't seem to be an easy way to convert the array element-by-element because expects a pointer to an object of the underlying type, so I'd have to write a switch statement for each variant type. Surely there's an easier way? One suggestion was to use the ATL template, but since it's a template, the underlying type of the array needs to be known at compile time, but we don't know the underlyin...

Sep 20, 2012
Post comments count 0
Post likes count 1

How do I invoke a verb on an IShellItemArray?

Raymond Chen

A customer wanted to invoke a command on multiple items at once. I have an , and I want to invoke a verb with that array as the parameter. I know that I can invoke a verb on a single by the code below, but how do I pass an entire array? The function invokes the command by extracting the pidl, then asking to invoke the command on the pidl. A limitation of is that it can invoke on only one pidl. What if you want to invoke it on a bunch of pidls at once? (Doing it all at once gives the target program the opportunity to optimize the multi-target invoke.) As noted in the documentation, passing flag tel...

Sep 19, 2012
Post comments count 0
Post likes count 1

Does the CopyFile function verify that the data reached its final destination successfully?

Raymond Chen

It just writes data.

Sep 18, 2012
Post comments count 0
Post likes count 1

The day I stole Joe Belfiore's mouse

Raymond Chen

He's now the head demo-monkey/cheerleader for Windows Phone, but back in the old days, Joe Belfiore was the head demo-monkey/cheerleader for the Windows 95 user interface design. A team-wide meeting was held to show off the new interface that they had developed. Wow look, we have a Start menu (though it wasn't known by that name yet), a taskbar (though it wasn't known by that name yet), shortcuts, a Close button (in the upper right corner), property sheets, all that good stuff. At that time, I was still developing my thermonuclear skills and in particular was cultivating the skill of asking challenging qu...

Sep 17, 2012
Post comments count 0
Post likes count 1

How do you deal with an input stream that may or may not contain Unicode data?

Raymond Chen

Dewi Morgan reinterpreted a question from a Suggestion Box of times past as "How do you deal with an input stream that may or may not contain Unicode data?" A related question from Dave wondered how applications that use to store data could ensure that the data is interpreted in the same code page by the recipient. "If I send a .txt file to a person in China, do they just go through code pages until it seems to display correctly?" These questions are additional manifestations of Keep your eye on the code page. When you store data, you need to have some sort of agreement (either explicit or implicit) with th...

Sep 14, 2012
Post comments count 0
Post likes count 1

Raymond learns about some of the things people do to get banned on Xbox LIVE

Raymond Chen

I still enjoy dropping in on Why Was I Banned? every so often, but not being a l33t Xbox haxxor, I don't understand a lot of the terminology. Fortunately, some of my colleagues were kind enough to explain them to me. (And now I'm explaining them to you so that you don't have to look as stupid asking them.) A modded lobby is a pre-game lobby (a server you connect to in order to find other people to play with or against) that has been modified (modded) with carefully-crafted parameters so that they grant people who visit them various advantages. For example, the reward for winning the game could be some absurd nu...

Sep 14, 2012
Post comments count 0
Post likes count 1

IShellFolder::BindToObject is a high-traffic method; don't do any heavy lifting

Raymond Chen

A customer observed that once the user visited their shell extension, Explorer ran really slowly. (Actually, it took a while just to get to this point, but I'll skip the early investigations because they aren't relevant to the story.) Some investigation showed that Explorer's tree view was calling into the shell extension, which was in turn hanging the shell for several seconds at a time. Explorer was calling into the shell extension because the node was in the folder tree view, and Explorer was doing a little bookkeeping to synchronize the folder state with the view. The node referred to a server that was no lo...