Showing tag results for Code

Sep 20, 2012
Post comments count0
Post likes count0

How do I invoke a verb on an IShellItemArray?

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

Code
Sep 17, 2012
Post comments count0
Post likes count0

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

Raymond Chen
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 per...

Code
Sep 14, 2012
Post comments count0
Post likes count0

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

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

Code
Sep 10, 2012
Post comments count0
Post likes count0

When you transfer control across stack frames, all the frames in between need to be in on the joke

Raymond Chen
Raymond Chen

Chris Hill suggests discussing the use of structured exception handling as it relates to the window manager, and specifically the implications for applications which raise exceptions from a callback. If you plan on raising an exception and handling it in a function higher up the stack, all the stack frames in between need to be be in on your li...

Code
Sep 6, 2012
Post comments count0
Post likes count0

You can't rule out a total breakdown of normal functioning, because a total breakdown of normal functioning could manifest itself as anything

Raymond Chen
Raymond Chen

A customer was attempting to study a problem that their analysis traced back to the function returning . Is it a valid conclusion that there is no heap corruption? While heap corruption may not be the avenue of investigation you'd first pursue, you can't rule it out. In the presence of a total breakdown of normal functioning, anything can happ...

Code
Aug 31, 2012
Post comments count0
Post likes count0

Adventures in undefined behavior: The premature downcast

Raymond Chen
Raymond Chen

A customer encountered the following problem: The function converts the cookie back to a object, and then checks if the object is a object by calling . If so, then it does some more stuff to figure out what type of paint to buy. (Note to nitpickers: The actual scenario was not like this, but I presented it this way to illustrate the point....

Code
Aug 30, 2012
Post comments count0
Post likes count0

I'm not calling a virtual function from my constructor or destructor, but I'm still getting a __purecall error

Raymond Chen
Raymond Chen

Some time ago, I described what is for: It's to detect the cases where you call a virtual method with no implementation (a so-called pure virtual method). This can happen during object constructor or destruction, since those are times when you can validly have a partially-implemented object. Well, there's another case this can happen: If the obj...

Code
Aug 28, 2012
Post comments count0
Post likes count0

Command line tool to manage Windows 7 Libraries, with source code

Raymond Chen
Raymond Chen

A customer asked if there was a command-line tool for managing Windows 7 Libraries so that they could create and deploy libraries across their organization. Not only is there such a tool, it even comes with source code. The Shell Library Command Line Sample shows how to manage Windows 7 libraries programmatically via the interface....

CodeTips/Support
Aug 23, 2012
Post comments count0
Post likes count0

Wait, you never said that I had to initialize the object before I used it!

Raymond Chen
Raymond Chen

A customer reported that they were having trouble creating slim reader/writer locks at runtime. They simplified the issue to a short program: "What is the correct way of creating an via the operator?" It wasn't long before somebody noted that nowhere in the code is the function called. "Oh, yeah, thanks for catching that. It looks like ...

Code
Aug 20, 2012
Post comments count0
Post likes count0

How do I customize how my application windows are grouped in the Taskbar?

Raymond Chen
Raymond Chen

Benjamin Smedberg wants to know how to customize the icon used in the Taskbar for applications that are grouped, when the application is a runtime for multiple applications. (This is the other scenario I hinted at last time.) Actually, customizing the icon is only part of what you want to happen when your application is a runtime. In that case...

Code